From cc76ffc5d23bdde848344a6dd558e5149eeb0a19 Mon Sep 17 00:00:00 2001 From: Max Neunhoeffer Date: Mon, 21 Mar 2016 23:00:44 +0100 Subject: [PATCH] Fix bug that callback was not called for singleRequest case in ClusterComm. --- arangod/Cluster/ClusterComm.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arangod/Cluster/ClusterComm.cpp b/arangod/Cluster/ClusterComm.cpp index bf3dda3ba3..5f764a33ca 100644 --- a/arangod/Cluster/ClusterComm.cpp +++ b/arangod/Cluster/ClusterComm.cpp @@ -1126,6 +1126,28 @@ void ClusterCommThread::run() { } } + if (op->result.single) { + // For single requests this is it, either it worked and is ready + // or there was an error (timeout or other). If there is a callback, + // we have to call it now: + if (nullptr != op->callback.get()) { + if (op->result.status == CL_COMM_SENDING) { + op->result.status = CL_COMM_SENT; + } + if ((*op->callback.get())(&op->result)) { + // This is fully processed, so let's remove it from the queue: + CONDITION_LOCKER(locker, cc->somethingToSend); + auto i = cc->toSendByOpID.find(op->result.operationID); + TRI_ASSERT(i != cc->toSendByOpID.end()); + auto q = i->second; + cc->toSendByOpID.erase(i); + cc->toSend.erase(q); + delete op; + continue; // do not move to the received queue but forget it + } + } + } + cc->moveFromSendToReceived(op->result.operationID); // Potentially it was dropped in the meantime, then we forget about it. }