diff --git a/inspector/ws_server.cpp b/inspector/ws_server.cpp index 08f64103a2a9e9c48213d4d8900d63fa37066c0e..50e9c5f676cf58b98809458972e1ca3b51fc8e32 100644 --- a/inspector/ws_server.cpp +++ b/inspector/ws_server.cpp @@ -50,6 +50,7 @@ void WsServer::RunServer() CommProtocol::endpoint endPoint(sockName); #endif ioContext_ = std::make_unique(); + terminateState_ = true; CommProtocol::socket socket(*ioContext_); CommProtocol::acceptor acceptor(*ioContext_, endPoint); auto& connectFlag = connectState_; @@ -90,6 +91,9 @@ void WsServer::RunServer() void WsServer::StopServer() { LOGI("WsServer StopServer"); + while (!terminateState_) { + usleep(DEBUGGER_WAIT_TIME); + } terminateExecution_ = true; if (!connectState_) { ioContext_->stop(); diff --git a/inspector/ws_server.h b/inspector/ws_server.h index f6bc44dac463cf124278ca4462219d31257974ce..ec04557ad3f2155bd83a80720c640e88a5768e4f 100644 --- a/inspector/ws_server.h +++ b/inspector/ws_server.h @@ -50,8 +50,10 @@ public: void SendReply(const std::string& message) const; private: - std::atomic connectState_ {false}; + static constexpr int32_t DEBUGGER_WAIT_TIME = 1000; + std::atomic connectState_ { false }; std::atomic terminateExecution_ { false }; + std::atomic terminateState_ { false }; [[maybe_unused]] int32_t instanceId_ {0}; pthread_t tid_ {0}; std::string componentName_ {};