[VOL-1913] Replies with errors of the form "transaction-not-acquired" are now ignored.
Also had to add a conditional branch in case no valid responses are received (the last thread to exit must clean up the connection).
The rw cores will now respond with a "transaction-not-acquired" error in place of "failed-to-seize-request" or COMPLETED_BY_OTHER.
Change-Id: I199d4a0091ba4fc1db5b8097adbad951408e5034
diff --git a/rw_core/core/grpc_nbi_api_handler.go b/rw_core/core/grpc_nbi_api_handler.go
index 7f45875..987a3f6 100755
--- a/rw_core/core/grpc_nbi_api_handler.go
+++ b/rw_core/core/grpc_nbi_api_handler.go
@@ -138,7 +138,7 @@
} else if txn.Acquired(timeout) {
return txn, nil
} else {
- return nil, errors.New("failed-to-seize-request")
+ return nil, errorTransactionNotAcquired
}
}
@@ -166,7 +166,7 @@
log.Debugw("acquired-transaction", log.Fields{"transaction-timeout": timeout})
return txn, nil
} else {
- return nil, errors.New("failed-to-seize-request")
+ return nil, errorTransactionNotAcquired
}
} else {
if txn.Monitor(timeout) {
@@ -174,7 +174,7 @@
return txn, nil
} else {
log.Debugw("transaction-completed-by-other", log.Fields{"timeout": timeout, "waited-time": time.Since(t)})
- return nil, errors.New(string(COMPLETED_BY_OTHER))
+ return nil, errorTransactionNotAcquired
}
}
}
@@ -557,8 +557,8 @@
if handler.competeForTransaction() {
if txn, err := handler.takeRequestOwnership(ctx, &utils.DeviceID{Id: id.Id}); err != nil {
- // Remove the device in memory
- if err.Error() == (errors.New(string(COMPLETED_BY_OTHER)).Error()) {
+ if err == errorTransactionNotAcquired && !handler.core.deviceOwnership.OwnedByMe(&utils.DeviceID{Id: id.Id}) {
+ // Remove the device in memory
handler.deviceMgr.stopManagingDevice(id.Id)
}
return new(empty.Empty), err