in wangle/acceptor/EvbHandshakeHelper.cpp [86:136]
void EvbHandshakeHelper::connectionReady(
folly::AsyncTransport::UniquePtr transport,
std::string nextProtocol,
SecureTransportType secureTransportType,
folly::Optional<SSLErrorEnum> sslErr) noexcept {
DCHECK_EQ(transport->getEventBase(), handshakeEvb_);
auto transition =
tryTransition(HandshakeState::Started, HandshakeState::Callback);
if (!transition.first) {
VLOG(5) << "Ignoring call to connectionReady(), expected state to be "
<< static_cast<unsigned>(HandshakeState::Started)
<< " but actual state was "
<< static_cast<unsigned>(transition.second);
return;
}
transport->detachEventBase();
handshakeEvb_->runInLoop(
[this,
secureTransportType,
sslErr,
transport = std::move(transport),
nextProtocol = std::move(nextProtocol)]() mutable {
originalEvb_->runInEventBaseThread(
[this,
secureTransportType,
sslErr,
transport = std::move(transport),
nextProtocol = std::move(nextProtocol)]() mutable {
DCHECK(callback_);
VLOG(5) << "calling underlying callback connectionReady";
transport->attachEventBase(originalEvb_);
// If a dropConnection call occured by the time this lambda runs,
// we don't want to fire the callback. (See Case 2)
if (dropConnectionGuard_.has_value()) {
dropConnectionGuard_.reset();
return;
}
callback_->connectionReady(
std::move(transport),
std::move(nextProtocol),
secureTransportType,
sslErr);
});
},
/* thisIteration = */ true);
}