]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/ProtocolV2: send_keepalive under the scope of lock 26668/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Fri, 1 Mar 2019 01:33:14 +0000 (09:33 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Fri, 1 Mar 2019 01:38:27 +0000 (09:38 +0800)
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 <xie.xingguo@zte.com.cn>
src/msg/async/ProtocolV2.cc

index ebf6dcea4074af42b742d52453dd05b876526c11..019a6feae750972eeced5b80e6a998670301da6a 100644 (file)
@@ -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);
   }