]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Revert "msg/async/ProtocolV[12]: unlock the `write_lock` before doing I/O"
authorLaura Flores <lflores@ibm.com>
Thu, 6 Feb 2025 17:55:57 +0000 (11:55 -0600)
committerLaura Flores <lflores@ibm.com>
Thu, 6 Feb 2025 17:55:57 +0000 (11:55 -0600)
This reverts commit f07cd30733a674c3577bfa1853bd722851783b97.
The PR was mistakenly merged after some regressions were found
in teuthology.

Signed-off-by: Laura Flores <lflores@ibm.com>
src/msg/async/ProtocolV1.cc
src/msg/async/ProtocolV2.cc

index 26c22128eb4f5ff7e4e6f1dc51da055583976b8a..a53f6389c3101da81541ea93fbaf69802e5da269 100644 (file)
@@ -222,7 +222,7 @@ void ProtocolV1::send_message(Message *m) {
     is_prepared = true;
   }
 
-  std::unique_lock l{connection->write_lock};
+  std::lock_guard<std::mutex> l(connection->write_lock);
   // "features" changes will change the payload encoding
   if (can_fast_prepare &&
       (can_write == WriteStatus::NOWRITE || connection->get_features() != f)) {
@@ -245,11 +245,6 @@ void ProtocolV1::send_message(Message *m) {
                    << dendl;
     if (can_write != WriteStatus::REPLACING && !write_in_progress) {
       write_in_progress = true;
-
-      /* unlock the mutex now because dispatch_event_external() may
-         block waiting for another mutex */
-      l.unlock();
-
       connection->center->dispatch_event_external(connection->write_handler);
     }
   }
@@ -275,14 +270,9 @@ void ProtocolV1::prepare_send_message(uint64_t features, Message *m,
 
 void ProtocolV1::send_keepalive() {
   ldout(cct, 10) << __func__ << dendl;
-  std::unique_lock l{connection->write_lock};
+  std::lock_guard<std::mutex> l(connection->write_lock);
   if (can_write != WriteStatus::CLOSED) {
     keepalive = true;
-
-    /* unlock the mutex now because dispatch_event_external() may
-       block waiting for another mutex */
-    l.unlock();
-
     connection->center->dispatch_event_external(connection->write_handler);
   }
 }
index eeabc374e7eda0a9bc420c472590ce72fbfa016e..55481056c60672bf5707b7e69e3499f9e13df044 100644 (file)
@@ -440,7 +440,7 @@ void ProtocolV2::send_message(Message *m) {
     is_prepared = false;
   }
 
-  std::unique_lock l{connection->write_lock};
+  std::lock_guard<std::mutex> l(connection->write_lock);
   // "features" changes will change the payload encoding
   if (can_fast_prepare && (!can_write || connection->get_features() != f)) {
     // ensure the correctness of message encoding
@@ -464,11 +464,6 @@ void ProtocolV2::send_message(Message *m) {
                    << dendl;
     if (((!replacing && can_write) || state == STANDBY) && !write_in_progress) {
       write_in_progress = true;
-
-      /* unlock the mutex now because dispatch_event_external() may
-         block waiting for another mutex */
-      l.unlock();
-
       connection->center->dispatch_event_external(connection->write_handler);
     }
   }
@@ -476,14 +471,9 @@ void ProtocolV2::send_message(Message *m) {
 
 void ProtocolV2::send_keepalive() {
   ldout(cct, 10) << __func__ << dendl;
-  std::unique_lock l{connection->write_lock};
+  std::lock_guard<std::mutex> l(connection->write_lock);
   if (state != CLOSED) {
     keepalive = true;
-
-    /* unlock the mutex now because dispatch_event_external() may
-       block waiting for another mutex */
-    l.unlock();
-
     connection->center->dispatch_event_external(connection->write_handler);
   }
 }