@@ -440,7 +440,7 @@ void ProtocolV2::send_message(Message *m) {
440440 is_prepared = false ;
441441 }
442442
443- std::unique_lock l{ connection->write_lock } ;
443+ std::lock_guard<std::mutex> l ( connection->write_lock ) ;
444444 // "features" changes will change the payload encoding
445445 if (can_fast_prepare && (!can_write || connection->get_features () != f)) {
446446 // ensure the correctness of message encoding
@@ -464,26 +464,16 @@ void ProtocolV2::send_message(Message *m) {
464464 << dendl;
465465 if (((!replacing && can_write) || state == STANDBY) && !write_in_progress) {
466466 write_in_progress = true ;
467-
468- /* unlock the mutex now because dispatch_event_external() may
469- block waiting for another mutex */
470- l.unlock ();
471-
472467 connection->center ->dispatch_event_external (connection->write_handler );
473468 }
474469 }
475470}
476471
477472void ProtocolV2::send_keepalive () {
478473 ldout (cct, 10 ) << __func__ << dendl;
479- std::unique_lock l{ connection->write_lock } ;
474+ std::lock_guard<std::mutex> l ( connection->write_lock ) ;
480475 if (state != CLOSED) {
481476 keepalive = true ;
482-
483- /* unlock the mutex now because dispatch_event_external() may
484- block waiting for another mutex */
485- l.unlock ();
486-
487477 connection->center ->dispatch_event_external (connection->write_handler );
488478 }
489479}
@@ -1653,8 +1643,8 @@ CtPtr ProtocolV2::handle_keepalive2(ceph::bufferlist &payload)
16531643
16541644 ldout (cct, 30 ) << __func__ << " got KEEPALIVE2 tag ..." << dendl;
16551645
1656- auto keepalive_ack_frame = KeepAliveFrameAck::Encode (keepalive_frame.timestamp ());
16571646 connection->write_lock .lock ();
1647+ auto keepalive_ack_frame = KeepAliveFrameAck::Encode (keepalive_frame.timestamp ());
16581648 if (!append_frame (keepalive_ack_frame)) {
16591649 connection->write_lock .unlock ();
16601650 return _fault ();
0 commit comments