diff --git a/connections/implementation/base_pcp_handler.cc b/connections/implementation/base_pcp_handler.cc index 38729c65..4188aa3a 100644 --- a/connections/implementation/base_pcp_handler.cc +++ b/connections/implementation/base_pcp_handler.cc @@ -84,7 +84,7 @@ BasePcpHandler::~BasePcpHandler() { } void BasePcpHandler::Shutdown() { - if (stop_) return; + if (closed_.Set(true)) return; NEARBY_LOGS(INFO) << "Initiating shutdown of BasePcpHandler(" << strategy_.GetName() << ")"; DisconnectFromEndpointManager(); diff --git a/connections/implementation/base_pcp_handler.h b/connections/implementation/base_pcp_handler.h index c149e360..de8248e9 100644 --- a/connections/implementation/base_pcp_handler.h +++ b/connections/implementation/base_pcp_handler.h @@ -609,6 +609,7 @@ class BasePcpHandler : public PcpHandler, Strategy strategy_{PcpToStrategy(pcp_)}; EncryptionRunner encryption_runner_; BwuManager* bwu_manager_; + AtomicBoolean closed_{false}; }; } // namespace connections