]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/http: async_wait() uses async_initiate
authorCasey Bodley <cbodley@redhat.com>
Thu, 15 Feb 2024 03:42:56 +0000 (22:42 -0500)
committerCasey Bodley <cbodley@redhat.com>
Mon, 13 May 2024 16:13:40 +0000 (12:13 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_http_client.cc

index a1873586b013f914bc692d361f76f52e7da9bcc3..50c0f6a775ec7e46df52fa28f4eaf2a931f812a9 100644 (file)
@@ -61,15 +61,13 @@ struct rgw_http_req_data : public RefCountedObject {
     memset(error_buf, 0, sizeof(error_buf));
   }
 
-  template <typename ExecutionContext, typename CompletionToken>
-  auto async_wait(ExecutionContext& ctx, CompletionToken&& token) {
-    boost::asio::async_completion<CompletionToken, Signature> init(token);
-    auto& handler = init.completion_handler;
-    {
-      std::unique_lock l{lock};
-      completion = Completion::create(ctx.get_executor(), std::move(handler));
-    }
-    return init.result.get();
+  template <typename Executor, typename CompletionToken>
+  auto async_wait(const Executor& ex, CompletionToken&& token) {
+    return boost::asio::async_initiate<CompletionToken, Signature>(
+        [this] (auto handler, auto ex) {
+          std::unique_lock l{lock};
+          completion = Completion::create(ex, std::move(handler));
+        }, token, ex);
   }
 
   int wait(optional_yield y) {
@@ -77,10 +75,9 @@ struct rgw_http_req_data : public RefCountedObject {
       return ret;
     }
     if (y) {
-      auto& context = y.get_io_context();
       auto& yield = y.get_yield_context();
       boost::system::error_code ec;
-      async_wait(context, yield[ec]);
+      async_wait(yield.get_executor(), yield[ec]);
       return -ec.value();
     }
     // work on asio threads should be asynchronous, so warn when they block