diff options
author | daniel-mdb <96069285+daniel-mdb@users.noreply.github.com> | 2022-05-03 10:24:12 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-03 10:59:03 +0000 |
commit | ea186dba422b15d4036cf4fb91f542ed83e6b7a8 (patch) | |
tree | f7c27d4a81217dc42877887e4604440abc97c776 /src/mongo/executor/network_interface_tl.h | |
parent | 2d42bc1dece6cde630ca308be4914f655ffa8f76 (diff) | |
download | mongo-ea186dba422b15d4036cf4fb91f542ed83e6b7a8.tar.gz |
SERVER-65292 NetworkInterfaceTL::shutdown may race with the destructor
Diffstat (limited to 'src/mongo/executor/network_interface_tl.h')
-rw-r--r-- | src/mongo/executor/network_interface_tl.h | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/mongo/executor/network_interface_tl.h b/src/mongo/executor/network_interface_tl.h index 158e4b0a679..8564413806a 100644 --- a/src/mongo/executor/network_interface_tl.h +++ b/src/mongo/executor/network_interface_tl.h @@ -353,14 +353,34 @@ private: std::unique_ptr<rpc::EgressMetadataHook> _metadataHook; - // We start in kDefault, transition to kStarted after startup() is complete and enter kStopped - // at the first call to shutdown() - enum State : int { + // We start in kDefault, transition to kStarted after a call to startup completes. + // Enter kStopping at the first call to shutdown and transition to kStopped + // when the call completes. + enum State { kDefault, kStarted, + kStopping, kStopped, }; - AtomicWord<State> _state; + + friend StringData toString(State s) { + return std::array{ + "Default"_sd, + "Started"_sd, + "Stopping"_sd, + "Stopped"_sd, + } + .at(s); + } + + // This condition variable is dedicated to block a thread calling this class + // destructor, strictly when another thread is performing the network + // interface shutdown which depends on the _ioThread termination and may + // take an undeterministic amount of time to return. + mutable stdx::mutex _stateMutex; // NOLINT + stdx::condition_variable _stoppedCV; + State _state; + stdx::thread _ioThread; Mutex _inProgressMutex = |