summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/transport/transport_layer_asio.cpp8
-rw-r--r--src/mongo/transport/transport_layer_asio_test.cpp5
2 files changed, 9 insertions, 4 deletions
diff --git a/src/mongo/transport/transport_layer_asio.cpp b/src/mongo/transport/transport_layer_asio.cpp
index 2a1ecc5ccaf..55713327b4b 100644
--- a/src/mongo/transport/transport_layer_asio.cpp
+++ b/src/mongo/transport/transport_layer_asio.cpp
@@ -1219,9 +1219,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(); });
@@ -1240,7 +1241,6 @@ void TransportLayerASIO::shutdown() {
// We were already stopped
return;
}
-
lk.unlock();
_timerService->stop();
lk.lock();
diff --git a/src/mongo/transport/transport_layer_asio_test.cpp b/src/mongo/transport/transport_layer_asio_test.cpp
index e1a60bf75f4..522cb3ab39c 100644
--- a/src/mongo/transport/transport_layer_asio_test.cpp
+++ b/src/mongo/transport/transport_layer_asio_test.cpp
@@ -486,6 +486,11 @@ TEST_F(TransportLayerASIOWithServiceContextTest, TimerServiceCanStopMoreThanOnce
}
}
+TEST_F(TransportLayerASIOWithServiceContextTest, TransportStartAfterShutDown) {
+ tla().shutdown();
+ ASSERT_EQ(tla().start(), transport::TransportLayer::ShutdownStatus);
+}
+
#ifdef MONGO_CONFIG_SSL
#ifndef _WIN32
// TODO SERVER-62035: enable the following on Windows.