aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/clients/httpwsclient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenhttp/clients/httpwsclient.cpp')
-rw-r--r--src/zenhttp/clients/httpwsclient.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/zenhttp/clients/httpwsclient.cpp b/src/zenhttp/clients/httpwsclient.cpp
index 36a6f081b..9497dadb8 100644
--- a/src/zenhttp/clients/httpwsclient.cpp
+++ b/src/zenhttp/clients/httpwsclient.cpp
@@ -351,9 +351,8 @@ struct HttpWsClient::Impl
}
// Echo masked close frame if we haven't sent one yet
- if (!m_CloseSent)
+ if (!m_CloseSent.exchange(true))
{
- m_CloseSent = true;
std::vector<uint8_t> CloseFrame = WsFrameCodec::BuildMaskedCloseFrame(Code);
EnqueueWrite(std::move(CloseFrame));
}
@@ -479,9 +478,8 @@ struct HttpWsClient::Impl
return;
}
- if (!m_CloseSent)
+ if (!m_CloseSent.exchange(true))
{
- m_CloseSent = true;
std::vector<uint8_t> CloseFrame = WsFrameCodec::BuildMaskedCloseFrame(Code, Reason);
EnqueueWrite(std::move(CloseFrame));
}
@@ -515,7 +513,7 @@ struct HttpWsClient::Impl
bool m_IsWriting = false;
std::atomic<bool> m_IsOpen{false};
- bool m_CloseSent = false;
+ std::atomic<bool> m_CloseSent{false};
};
//////////////////////////////////////////////////////////////////////////