From c2e34c7513bff1d3aba2996b6e38d15af10ffca1 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 15 Feb 2022 18:12:00 -0500 Subject: [PATCH] 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 --- src/librbd/migration/HttpClient.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/librbd/migration/HttpClient.cc b/src/librbd/migration/HttpClient.cc index 679c2bb073380..90d5723ed84cb 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 { -- 2.39.5