Skip to content

Commit

Permalink
fix wrong lambda call bug
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Uri Hindri authored and facebook-github-bot committed Nov 15, 2024
1 parent efba618 commit b92b323
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
28 changes: 28 additions & 0 deletions quic/api/QuicTransportBaseLite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,34 @@ inline std::ostream& operator<<(
return os;
}

QuicTransportBaseLite::QuicTransportBaseLite(
std::shared_ptr<QuicEventBase> evb,
std::unique_ptr<QuicAsyncUDPSocket> 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 {
Expand Down
25 changes: 1 addition & 24 deletions quic/api/QuicTransportBaseLite.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,7 @@ class QuicTransportBaseLite : virtual public QuicSocketLite,
QuicTransportBaseLite(
std::shared_ptr<QuicEventBase> evb,
std::unique_ptr<QuicAsyncUDPSocket> 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.
Expand Down

0 comments on commit b92b323

Please sign in to comment.