From b9141e94931c5ddb4fb1687da08f5c75f8ad6703 Mon Sep 17 00:00:00 2001 From: Sam Lang Date: Mon, 25 Mar 2013 13:13:28 -0500 Subject: [PATCH] client: Cleanup request signaling 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 --- src/client/Client.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 59f32ef3b74..ec4e22c57ed 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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;