0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-47507 Cancel all remaining egress commands on shutdown

This commit is contained in:
Ben Caimano 2020-04-13 12:36:17 -04:00 committed by Evergreen Agent
parent 0aab1bdb1f
commit 8ae6c7dc3c

View File

@ -201,6 +201,25 @@ void NetworkInterfaceTL::shutdown() {
LOGV2_DEBUG(22594, 2, "Shutting down network interface.");
// Cancel any remaining commands. Any attempt to register new commands will throw.
auto inProgress = [&] {
stdx::lock_guard lk(_inProgressMutex);
return std::exchange(_inProgress, {});
}();
for (auto& [_, weakCmdState] : inProgress) {
auto cmdState = weakCmdState.lock();
if (!cmdState) {
continue;
}
if (!cmdState->finishLine.arriveStrongly()) {
continue;
}
cmdState->fulfillFinalPromise(kNetworkInterfaceShutdownInProgress);
}
// Stop the reactor/thread first so that nothing runs on a partially dtor'd pool.
_reactor->stop();