From dee0e1ed67b8fe6054805f6ba73e7926a704ce77 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Fri, 1 Mar 2019 09:33:14 +0800 Subject: [PATCH] msg/async/ProtocolV2: send_keepalive under the scope of lock Dropping lock is dangerous and could be race-prone. Any time the lock is dropped we need to reverify the connection state. send_keepalive under the scope of lock should be just fine since it does not introduce any extra lock dependencies. Signed-off-by: xie xingguo --- src/msg/async/ProtocolV2.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index ebf6dcea4074a..019a6feae7509 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -2646,12 +2646,10 @@ CtPtr ProtocolV2::handle_existing_connection(AsyncConnectionRef existing) { ceph_assert(connection->peer_addrs->msgr2_addr() > messenger->get_myaddrs().msgr2_addr()); - existing->lock.unlock(); // make sure we follow through with opening the existing - // connection (if it isn't yet open) since we know the peer - // has something to send to us. + // connection (if it isn't yet open) since we know the peer + // has something to send to us. existing->send_keepalive(); - existing->lock.lock(); auto wait = WaitFrame::Encode(session_stream_handlers); return WRITE(wait, "wait", read_frame); } -- 2.39.5