From: Casey Bodley Date: Tue, 15 Feb 2022 23:12:00 +0000 (-0500) Subject: rbd: avoid get_callback_adapter() for tcp_stream::async_connect() X-Git-Tag: v18.0.0~1349^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F45062%2Fhead;p=ceph.git rbd: avoid get_callback_adapter() for tcp_stream::async_connect() 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` and `completion_token_for`), 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 --- diff --git a/src/librbd/migration/HttpClient.cc b/src/librbd/migration/HttpClient.cc index 679c2bb0733..90d5723ed84 100644 --- a/src/librbd/migration/HttpClient.cc +++ b/src/librbd/migration/HttpClient.cc @@ -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 {