]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Cleanup request signaling
authorSam Lang <sam.lang@inktank.com>
Mon, 25 Mar 2013 18:13:28 +0000 (13:13 -0500)
committerSam Lang <sam.lang@inktank.com>
Tue, 26 Mar 2013 14:25:19 +0000 (09:25 -0500)
Split up the conditionals handling unsafe reply
and signaling the caller to improve readability.
The overall behavior of the code remains the same.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
src/client/Client.cc

index 59f32ef3b746c671b3b9a88f25f21dee3a9c4711..ec4e22c57edfebb84d80c568a45bfbf8ebd77740 100644 (file)
@@ -1736,17 +1736,22 @@ void Client::handle_client_reply(MClientReply *reply)
   request->reply = reply;
   insert_trace(request, session);
 
-  if (!request->got_unsafe) {
+  // Handle unsafe reply
+  if (!is_safe) {
     request->got_unsafe = true;
     session->unsafe_requests.push_back(&request->unsafe_item);
+  }
 
+  // Only signal the caller once (on the first reply):
+  // Either its an unsafe reply, or its a safe reply and no unsafe reply was sent.
+  if (!is_safe || !request->got_unsafe) {
     Cond cond;
     request->dispatch_cond = &cond;
-    
+
     // wake up waiter
     ldout(cct, 20) << "handle_client_reply signalling caller " << (void*)request->caller_cond << dendl;
     request->caller_cond->Signal();
-    
+
     // wake for kick back
     while (request->dispatch_cond) {
       ldout(cct, 20) << "handle_client_reply awaiting kickback on tid " << tid << " " << &cond << dendl;