Skip to content

Commit

Permalink
Fix lock order inversion in TcpTransport
Browse files Browse the repository at this point in the history
  • Loading branch information
paullouisageneau committed Nov 22, 2024
1 parent 3c33ea0 commit a1bd307
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/impl/tcptransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,23 +200,23 @@ void TcpTransport::resolve() {
}

void TcpTransport::attempt() {
std::lock_guard lock(mSendMutex);
try {
std::lock_guard lock(mSendMutex);

if (state() != State::Connecting)
return; // Cancelled
if (state() != State::Connecting)
return; // Cancelled

if (mSock == INVALID_SOCKET) {
::closesocket(mSock);
mSock = INVALID_SOCKET;
}
if (mSock == INVALID_SOCKET) {
::closesocket(mSock);
mSock = INVALID_SOCKET;
}

if (mResolved.empty()) {
PLOG_WARNING << "Connection to " << mHostname << ":" << mService << " failed";
changeState(State::Failed);
return;
}
if (mResolved.empty()) {
PLOG_WARNING << "Connection to " << mHostname << ":" << mService << " failed";
changeState(State::Failed);
return;
}

try {
auto [addr, addrlen] = mResolved.front();
mResolved.pop_front();

Expand Down

0 comments on commit a1bd307

Please sign in to comment.