From 0cb47e56e6fc3b4b677681c8c637057dc806add1 Mon Sep 17 00:00:00 2001 From: Beats Date: Fri, 8 Nov 2024 20:44:51 -0400 Subject: [PATCH] fix --- src/server/network/connection/connection.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/server/network/connection/connection.cpp b/src/server/network/connection/connection.cpp index 96dfc373e8c..190140d0972 100644 --- a/src/server/network/connection/connection.cpp +++ b/src/server/network/connection/connection.cpp @@ -66,15 +66,14 @@ Connection::Connection(asio::io_context &initIoService, ConstServicePort_ptr ini socket(initIoService), m_msg() { } -void Connection::close(bool force) { +void Connection::close(const bool force) { const auto self = shared_from_this(); ConnectionManager::getInstance().releaseConnection(self); ip = 0; - if (connectionState.load() == CONNECTION_STATE_CLOSED) { + if (connectionState.exchange(CONNECTION_STATE_CLOSED) == CONNECTION_STATE_CLOSED) { return; } - connectionState.store(CONNECTION_STATE_CLOSED); if (protocol) { auto weakProtocol = std::weak_ptr(protocol); @@ -155,7 +154,7 @@ void Connection::acceptInternal(bool toggleParseHeader) { readTimer.async_wait([weakSelf](const std::error_code &error) { if (const auto self = weakSelf.lock()) { - Connection::handleTimeout(self, error); + handleTimeout(self, error); } });