summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/sys/rdma/RdmaIO.cpp38
-rw-r--r--cpp/src/qpid/sys/rdma/RdmaIO.h1
2 files changed, 22 insertions, 17 deletions
diff --git a/cpp/src/qpid/sys/rdma/RdmaIO.cpp b/cpp/src/qpid/sys/rdma/RdmaIO.cpp
index 6591c6e676..f0ae7e5d77 100644
--- a/cpp/src/qpid/sys/rdma/RdmaIO.cpp
+++ b/cpp/src/qpid/sys/rdma/RdmaIO.cpp
@@ -254,9 +254,8 @@ namespace Rdma {
return;
case EXIT:
// If we just processed completions we might need to delete ourselves
- if (notifyCallback && outstandingWrites == 0) {
- doStoppedCallback();
- }
+ // TODO: XXX: can we delete ourselves correctly in notifyPendingWrite()?
+ checkDrainedStopped();
return;
}
} while (true);
@@ -321,20 +320,8 @@ namespace Rdma {
} while (!state.boolCompareAndSwap(oldState, newState));
}
- // If we've got all the write confirmations and we're draining
- // We might get deleted in the drained callback so return immediately
- if (draining) {
- if (outstandingWrites == 0) {
- draining = false;
- doDrainedCallback();
- }
- return;
- }
-
- // We might need to delete ourselves
- if (notifyCallback && outstandingWrites == 0) {
- doStoppedCallback();
- }
+ // We might delete ourselves in here so return immediately
+ checkDrainedStopped();
}
void AsynchIO::processCompletions() {
@@ -448,6 +435,23 @@ namespace Rdma {
}
}
+ void AsynchIO::checkDrainedStopped() {
+ // If we've got all the write confirmations and we're draining
+ // We might get deleted in the drained callback so return immediately
+ if (draining) {
+ if (outstandingWrites == 0) {
+ draining = false;
+ doDrainedCallback();
+ }
+ return;
+ }
+
+ // We might need to delete ourselves
+ if (notifyCallback && outstandingWrites == 0) {
+ doStoppedCallback();
+ }
+ }
+
void AsynchIO::doDrainedCallback() {
NotifyCallback nc;
nc.swap(notifyCallback);
diff --git a/cpp/src/qpid/sys/rdma/RdmaIO.h b/cpp/src/qpid/sys/rdma/RdmaIO.h
index 5876646b96..8d5dbc5f3e 100644
--- a/cpp/src/qpid/sys/rdma/RdmaIO.h
+++ b/cpp/src/qpid/sys/rdma/RdmaIO.h
@@ -101,6 +101,7 @@ namespace Rdma {
void dataEvent();
void processCompletions();
void doWriteCallback();
+ void checkDrainedStopped();
void doStoppedCallback();
void doDrainedCallback();
};