]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osdc: use boost::asio::post for strand execution to prevent deadlocks
authorPatrick Donnelly <pdonnell@ibm.com>
Mon, 18 May 2026 14:21:24 +0000 (10:21 -0400)
committerPatrick Donnelly <pdonnell@ibm.com>
Mon, 18 May 2026 18:22:58 +0000 (14:22 -0400)
Using boost::asio::dispatch allows the executor to run the handler
inline if the current thread is already running on the strand. Because
we hold locks during dispatch, this inline execution can lead to
deadlocks. Changing to boost::asio::post guarantees deferred execution.

Signed-off-by: Patrick Donnelly <pdonnell@ibm.com>
src/osdc/Objecter.cc

index a4675ee23486bd5d446e00caef05689ff03df3fb..e14c76c00b0b1e636bbd9c804e76feebf250bc4e 100644 (file)
@@ -1059,7 +1059,7 @@ void Objecter::ms_fast_dispatch2(const MessageRef& m)
     auto s = static_cast<OSDSession*>(priv.get());
     if (s) {
       s->track_enqueue(m);
-      boost::asio::dispatch(s->strand, [this, priv, s, m]() {
+      boost::asio::post(s->strand, [this, priv, s, m]() {
         cref_t<MOSDOpReply> msg = ref_cast<MOSDOpReply>(m);
         s->track_dequeue(m);
         handle_osd_op_reply(std::move(msg));
@@ -1075,7 +1075,7 @@ void Objecter::ms_fast_dispatch2(const MessageRef& m)
     auto s = static_cast<OSDSession*>(priv.get());
     if (s) {
       s->track_enqueue(m);
-      boost::asio::dispatch(s->strand, [this, priv, s, m]() {
+      boost::asio::post(s->strand, [this, priv, s, m]() {
         cref_t<MWatchNotify> msg = ref_cast<MWatchNotify>(m);
         s->track_dequeue(m);
         handle_watch_notify(std::move(msg));
@@ -1100,7 +1100,7 @@ Dispatcher::dispatch_result_t Objecter::ms_dispatch2(const MessageRef& m)
     auto s = static_cast<OSDSession*>(priv.get());
     if (s) {
       s->track_enqueue(m);
-      boost::asio::dispatch(s->strand, [this, priv, s, m]() {
+      boost::asio::post(s->strand, [this, priv, s, m]() {
         cref_t<MOSDBackoff> msg = ref_cast<MOSDBackoff>(m);
         s->track_dequeue(m);
         handle_osd_backoff(std::move(msg));
@@ -1119,7 +1119,7 @@ Dispatcher::dispatch_result_t Objecter::ms_dispatch2(const MessageRef& m)
       auto s = static_cast<OSDSession*>(priv.get());
       if (s) {
         s->track_enqueue(m);
-        boost::asio::dispatch(s->strand, [this, priv, s, m]() {
+        boost::asio::post(s->strand, [this, priv, s, m]() {
           cref_t<MCommandReply> msg = ref_cast<MCommandReply>(m);
           s->track_dequeue(m);
           handle_command_reply(std::move(msg));