From b92b3232f4510073c7b562f1283fc9f1511fda98 Mon Sep 17 00:00:00 2001 From: Uri Hindri Date: Fri, 15 Nov 2024 13:34:22 -0800 Subject: [PATCH] fix wrong lambda call bug Summary: When using msvc and compiling quic with C++20 there's a weird issue that the Looper is initialized with the wrong callbacks. I suspect that this is because the constructor was creating the lambda as part of the header file. Moving the constructor code to the cpp file fixed the issue Reviewed By: hanidamlaj, kvtsoy Differential Revision: D65994029 fbshipit-source-id: 9c5f47b62d0e0c74b5bce05f926e437e6aa2a3ab --- quic/api/QuicTransportBaseLite.cpp | 28 ++++++++++++++++++++++++++++ quic/api/QuicTransportBaseLite.h | 25 +------------------------ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/quic/api/QuicTransportBaseLite.cpp b/quic/api/QuicTransportBaseLite.cpp index 150e4ee0b..c18711868 100644 --- a/quic/api/QuicTransportBaseLite.cpp +++ b/quic/api/QuicTransportBaseLite.cpp @@ -47,6 +47,34 @@ inline std::ostream& operator<<( return os; } +QuicTransportBaseLite::QuicTransportBaseLite( + std::shared_ptr evb, + std::unique_ptr socket, + bool useConnectionEndWithErrorCallback) + : evb_(std::move(evb)), + socket_(std::move(socket)), + useConnectionEndWithErrorCallback_(useConnectionEndWithErrorCallback), + lossTimeout_(this), + excessWriteTimeout_(this), + idleTimeout_(this), + keepaliveTimeout_(this), + ackTimeout_(this), + pathValidationTimeout_(this), + drainTimeout_(this), + pingTimeout_(this), + writeLooper_(new FunctionLooper( + evb_, + [this]() { pacedWriteDataToSocket(); }, + LooperType::WriteLooper)), + readLooper_(new FunctionLooper( + evb_, + [this]() { invokeReadDataAndCallbacks(true); }, + LooperType::ReadLooper)), + peekLooper_(new FunctionLooper( + evb_, + [this]() { invokePeekDataAndCallbacks(); }, + LooperType::PeekLooper)) {} + void QuicTransportBaseLite::onNetworkData( const folly::SocketAddress& peer, NetworkData&& networkData) noexcept { diff --git a/quic/api/QuicTransportBaseLite.h b/quic/api/QuicTransportBaseLite.h index cb18cf109..084122181 100644 --- a/quic/api/QuicTransportBaseLite.h +++ b/quic/api/QuicTransportBaseLite.h @@ -21,30 +21,7 @@ class QuicTransportBaseLite : virtual public QuicSocketLite, QuicTransportBaseLite( std::shared_ptr evb, std::unique_ptr socket, - bool useConnectionEndWithErrorCallback) - : evb_(evb), - socket_(std::move(socket)), - useConnectionEndWithErrorCallback_(useConnectionEndWithErrorCallback), - lossTimeout_(this), - excessWriteTimeout_(this), - idleTimeout_(this), - keepaliveTimeout_(this), - ackTimeout_(this), - pathValidationTimeout_(this), - drainTimeout_(this), - pingTimeout_(this), - writeLooper_(new FunctionLooper( - evb_, - [this]() { pacedWriteDataToSocket(); }, - LooperType::WriteLooper)), - readLooper_(new FunctionLooper( - evb_, - [this]() { invokeReadDataAndCallbacks(true); }, - LooperType::ReadLooper)), - peekLooper_(new FunctionLooper( - evb_, - [this]() { invokePeekDataAndCallbacks(); }, - LooperType::PeekLooper)) {} + bool useConnectionEndWithErrorCallback); /** * Invoked when we have to write some data to the wire.