Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/server/network/connection/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ Connection::Connection(asio::io_service &initIoService, ConstServicePort_ptr ini
}

void Connection::close(bool force) {
ConnectionManager::getInstance().releaseConnection(shared_from_this());

std::scoped_lock lock(connectionLock);
std::unique_lock lock(connectionLock);
ip = 0;

if (connectionState == CONNECTION_STATE_CLOSED) {
Expand All @@ -84,6 +82,9 @@ void Connection::close(bool force) {
if (messageQueue.empty() || force) {
closeSocket();
}

lock.unlock();
ConnectionManager::getInstance().releaseConnection(shared_from_this());
}

void Connection::closeSocket() {
Expand Down Expand Up @@ -371,8 +372,9 @@ void Connection::internalWorker() {
}

const auto &outputMessage = messageQueue.front();
auto currentProtocol = protocol;
lock.unlock();
protocol->onSendMessage(outputMessage);
currentProtocol->onSendMessage(outputMessage);
lock.lock();

internalSend(outputMessage);
Expand Down
Loading