avoid possible double termination. Use atomic swap

This commit is contained in:
orignal
2026-02-26 15:38:45 -05:00
parent 6a859cdb4e
commit 085babd1ea
2 changed files with 4 additions and 3 deletions
+2 -2
View File
@@ -563,9 +563,9 @@ namespace transport
void NTCP2Session::Terminate ()
{
if (!m_IsTerminated)
bool isTerminated = m_IsTerminated.exchange (true);
if (!isTerminated)
{
m_IsTerminated = true;
m_IsEstablished = false;
boost::system::error_code ec;
m_Socket.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);