]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/async: `io_context_pool` no longer moves from init function
authorAdam C. Emerson <aemerson@redhat.com>
Thu, 30 Apr 2026 00:57:35 +0000 (20:57 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Wed, 8 Jul 2026 21:06:08 +0000 (17:06 -0400)
Previously if we received an rvalue function object we would call a
moved-from object on all but the first thread. In practice this didn't
cause an issue, but only because of the functions we were passing.

Fixes: https://tracker.ceph.com/issues/76094
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/common/async/context_pool.h

index 6ec194ba77d276b13c5b33b13a8e3bd2f848d21c..12993e9ccc25a9d8a1718c75d3139e0c8b86e3bb 100644 (file)
@@ -18,7 +18,6 @@
 #define CEPH_COMMON_ASYNC_CONTEXT_POOL_H
 
 #include <concepts>
-#include <cstddef>
 #include <cstdint>
 #include <mutex>
 #include <optional>
@@ -54,7 +53,7 @@ public:
   }
   template<std::invocable<> Init>
   io_context_pool(std::int64_t threadcnt, Init&& init) noexcept {
-    start(threadcnt, std::move(init));
+    start(threadcnt, std::forward<Init>(init));
   }
   ~io_context_pool() {
     stop();
@@ -80,8 +79,8 @@ public:
       ioctx.restart();
       for (std::int16_t i = 0; i < threadcnt; ++i) {
        threadvec.emplace_back(make_named_thread("io_context_pool",
-                                                [this, init=std::move(init)] {
-                                                  std::move(init)();
+                                                [this, init] {
+                                                  init();
                                                   ioctx.run();
                                                 }));
       }