diff options
Diffstat (limited to 'src/mongo/transport/transport_layer_asio.cpp')
| -rw-r--r-- | src/mongo/transport/transport_layer_asio.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/mongo/transport/transport_layer_asio.cpp b/src/mongo/transport/transport_layer_asio.cpp index 85b5e816930..53076c84099 100644 --- a/src/mongo/transport/transport_layer_asio.cpp +++ b/src/mongo/transport/transport_layer_asio.cpp @@ -104,6 +104,7 @@ boost::optional<Status> maybeTcpFastOpenStatus; MONGO_FAIL_POINT_DEFINE(transportLayerASIOasyncConnectTimesOut); MONGO_FAIL_POINT_DEFINE(transportLayerASIOhangBeforeAccept); +MONGO_FAIL_POINT_DEFINE(transportLayerASIOasyncConnectReturnsConnectionError); #ifdef MONGO_CONFIG_SSL SSLConnectionContext::~SSLConnectionContext() = default; @@ -296,8 +297,11 @@ TransportLayerASIO::Options::Options(const ServerGlobalParams* params, maxConns(params->maxConns) { } -TransportLayerASIO::TimerService::TimerService() - : _reactor(std::make_shared<TransportLayerASIO::ASIOReactor>()) {} +TransportLayerASIO::TimerService::TimerService(Options opt) + : _reactor(std::make_shared<TransportLayerASIO::ASIOReactor>()) { + if (opt.spawn) + _spawn = std::move(opt.spawn); +} TransportLayerASIO::TimerService::~TimerService() { stop(); @@ -315,10 +319,13 @@ void TransportLayerASIO::TimerService::start() { auto lk = stdx::lock_guard(_mutex); auto precondition = State::kInitialized; if (_state.compareAndSwap(&precondition, State::kStarted)) { - _thread = stdx::thread([reactor = _reactor] { + _thread = _spawn([reactor = _reactor] { LOGV2_INFO(5490002, "Started a new thread for the timer service"); reactor->run(); - LOGV2_INFO(5490003, "Returning from the timer service thread"); + + if (!serverGlobalParams.quiet.load()) { + LOGV2_INFO(5490003, "Returning from the timer service thread"); + } }); } } @@ -733,6 +740,9 @@ Future<SessionHandle> TransportLayerASIO::asyncConnect( const ReactorHandle& reactor, Milliseconds timeout, std::shared_ptr<const SSLConnectionContext> transientSSLContext) { + if (MONGO_unlikely(transportLayerASIOasyncConnectReturnsConnectionError.shouldFail())) + return Status{ErrorCodes::ConnectionError, "Failing asyncConnect due to fail-point"}; + if (transientSSLContext) { uassert(ErrorCodes::InvalidSSLConfiguration, "Specified transient SSL context but connection SSL mode is not set", @@ -1295,9 +1305,10 @@ void TransportLayerASIO::_runListener() noexcept { Status TransportLayerASIO::start() { stdx::unique_lock lk(_mutex); - - // Make sure we haven't shutdown already - invariant(!_isShutdown); + if (_isShutdown) { + LOGV2(6986801, "Cannot start an already shutdown TransportLayer"); + return ShutdownStatus; + } if (_listenerOptions.isIngress()) { _listener.thread = stdx::thread([this] { _runListener(); }); @@ -1316,7 +1327,6 @@ void TransportLayerASIO::shutdown() { // We were already stopped return; } - lk.unlock(); _timerService->stop(); lk.lock(); |
