From: Jianpeng Ma Date: Thu, 7 Mar 2019 08:04:34 +0000 (+0800) Subject: msg/async V2: optimize check state by replace. X-Git-Tag: v15.0.0~198^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a21b37578f0b6e3bc976a73eed35405270ed04de;p=ceph.git msg/async V2: optimize check state by replace. state change by lock. So only check state when we release and reget lock. Signed-off-by: Jianpeng Ma --- diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index ef00c89272d8..d94c0d1f1d0a 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -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);