1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-08-08 09:42:06 +03:00

resetConnectionCallbacks() util function

Summary: In preparation for split callbacks

Reviewed By: mjoras, lnicco

Differential Revision: D30398849

fbshipit-source-id: 684c289283d0b06b5935fc1b8ab2dcbd126ec0ce
This commit is contained in:
Konstantin Tsoy
2021-08-25 16:14:31 -07:00
committed by Facebook GitHub Bot
parent 06ba2e0a41
commit ee59ae43c6
6 changed files with 12 additions and 8 deletions

View File

@@ -141,7 +141,7 @@ const folly::SocketAddress& QuicTransportBase::getLocalAddress() const {
}
QuicTransportBase::~QuicTransportBase() {
connCallback_ = nullptr;
resetConnectionCallbacks();
closeImpl(
std::make_pair(
@@ -179,7 +179,7 @@ void QuicTransportBase::close(
FOLLY_MAYBE_UNUSED auto self = sharedGuard();
// The caller probably doesn't need a conn callback any more because they
// explicitly called close.
connCallback_ = nullptr;
resetConnectionCallbacks();
// If we were called with no error code, ensure that we are going to write
// an application close, so the peer knows it didn't come from the transport.
@@ -220,7 +220,7 @@ void QuicTransportBase::closeGracefully() {
return;
}
FOLLY_MAYBE_UNUSED auto self = sharedGuard();
connCallback_ = nullptr;
resetConnectionCallbacks();
closeState_ = CloseState::GRACEFUL_CLOSING;
updatePacingOnClose(*conn_);
if (conn_->qLogger) {
@@ -420,7 +420,7 @@ void QuicTransportBase::closeImpl(
}
// can't invoke connection callbacks any more.
connCallback_ = nullptr;
resetConnectionCallbacks();
// Don't need outstanding packets.
conn_->outstandings.packets.clear();

View File

@@ -809,6 +809,10 @@ class QuicTransportBase : public QuicSocket {
}
}
void resetConnectionCallbacks() {
connCallback_ = nullptr;
}
std::atomic<folly::EventBase*> evb_;
std::unique_ptr<folly::AsyncUDPSocket> socket_;
ConnectionCallback* connCallback_{nullptr};

View File

@@ -210,7 +210,7 @@ class TestQuicTransport
}
~TestQuicTransport() override {
connCallback_ = nullptr;
resetConnectionCallbacks();
// we need to call close in the derived class.
closeImpl(
std::make_pair(

View File

@@ -36,7 +36,7 @@ class TestQuicTransport
~TestQuicTransport() override {
// we need to call close in the derived class.
connCallback_ = nullptr;
resetConnectionCallbacks();
closeImpl(
std::make_pair(
QuicErrorCode(LocalErrorCode::SHUTTING_DOWN),

View File

@@ -91,7 +91,7 @@ QuicClientTransport::~QuicClientTransport() {
VLOG(10) << "Destroyed connection to server=" << conn_->peerAddress;
// The caller probably doesn't need the conn callback after destroying the
// transport.
connCallback_ = nullptr;
resetConnectionCallbacks();
// Close without draining.
closeImpl(
std::make_pair(

View File

@@ -62,7 +62,7 @@ QuicServerTransport::~QuicServerTransport() {
VLOG(10) << "Destroyed connection to client=" << *this;
// The caller probably doesn't need the conn callback after destroying the
// transport.
connCallback_ = nullptr;
resetConnectionCallbacks();
closeImpl(
std::make_pair(
QuicErrorCode(LocalErrorCode::SHUTTING_DOWN),