]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: avoid get_callback_adapter() for tcp_stream::async_connect() 45062/head
authorCasey Bodley <cbodley@redhat.com>
Tue, 15 Feb 2022 23:12:00 +0000 (18:12 -0500)
committerCasey Bodley <cbodley@redhat.com>
Wed, 16 Feb 2022 19:53:46 +0000 (14:53 -0500)
works around a compilation failure in c++20 (with gcc 11.2 and boost
1.76) when choosing between two overloads of
`boost::beast::tcp_stream::async_connect()`

`get_callback_adapter()` returns a variadic lambda that matches the
concept for both overloads (`completion_token_for<ConnectHandler>`
and `completion_token_for<RangeConnectHandler>`), but compilation of
the wrapped lambda fails for the `ConnectHandler` overload because it
expects two arguments instead of one

instead of using `get_callback_adapter()` to convert the first argument
from `boost::system::error_code` to `int` for the wrapped lambda, do
this in the lambda itself

Fixes: https://tracker.ceph.com/issues/54303
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/librbd/migration/HttpClient.cc

index 679c2bb0733803cd37c9a44933cbbf0699b65176..90d5723ed84cb1de25983a026fe9151ceb0cb036 100644 (file)
@@ -603,8 +603,9 @@ protected:
 
     m_stream.async_connect(
       results,
-      asio::util::get_callback_adapter(
-        [on_finish](int r, auto endpoint) { on_finish->complete(r); }));
+      [on_finish](boost::system::error_code ec, const auto& endpoint) {
+        on_finish->complete(-ec.value());
+      });
   }
 
   void disconnect(Context* on_finish) override {
@@ -646,9 +647,9 @@ protected:
 
     boost::beast::get_lowest_layer(m_stream).async_connect(
       results,
-      asio::util::get_callback_adapter(
-        [this, on_finish](int r, auto endpoint) {
-          handle_connect(r, on_finish); }));
+      [this, on_finish](boost::system::error_code ec, const auto& endpoint) {
+        handle_connect(-ec.value(), on_finish);
+      });
   }
 
   void disconnect(Context* on_finish) override {