]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async V2: optimize check state by replace. 26812/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Thu, 7 Mar 2019 08:04:34 +0000 (16:04 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Thu, 7 Mar 2019 08:04:34 +0000 (16:04 +0800)
state change by lock. So only check state when we release and reget
lock.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/msg/async/ProtocolV2.cc

index ef00c89272d8ef23a943a55d248d3dbdd5a4a0f9..d94c0d1f1d0a83e4bf89c3157c965984c9d76db7 100644 (file)
@@ -1499,6 +1499,12 @@ CtPtr ProtocolV2::handle_message() {
     connection->logger->tinc(l_msgr_running_fast_dispatch_time,
                              connection->recv_start_time - fast_dispatch_time);
     connection->lock.lock();
+    // we might have been reused by another connection
+    // let's check if that is the case
+    if (state != READY) {
+      // yes, that was the case, let's do nothing
+      return nullptr;
+    }
   } else {
     connection->dispatch_queue->enqueue(message, message->get_priority(),
                                         connection->conn_id);
@@ -1506,12 +1512,6 @@ CtPtr ProtocolV2::handle_message() {
 
   handle_message_ack(current_header.ack_seq);
 
-  // we might have been reused by another connection
-  // let's check if that is the case
-  if (state != READY) {
-    // yes, that was the case, let's do nothing
-    return nullptr;
-  }
 
   if (need_dispatch_writer && connection->is_connected()) {
     connection->center->dispatch_event_external(connection->write_handler);