Skip to content

Commit e80ba94

Browse files
Merge pull request #1294 from paullouisageneau/tcptransport-sendmutex
Fix lock order inversion in TcpTransport
2 parents 5d3e79c + a1bd307 commit e80ba94

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/impl/tcptransport.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -200,23 +200,23 @@ void TcpTransport::resolve() {
200200
}
201201

202202
void TcpTransport::attempt() {
203-
std::lock_guard lock(mSendMutex);
203+
try {
204+
std::lock_guard lock(mSendMutex);
204205

205-
if (state() != State::Connecting)
206-
return; // Cancelled
206+
if (state() != State::Connecting)
207+
return; // Cancelled
207208

208-
if (mSock == INVALID_SOCKET) {
209-
::closesocket(mSock);
210-
mSock = INVALID_SOCKET;
211-
}
209+
if (mSock == INVALID_SOCKET) {
210+
::closesocket(mSock);
211+
mSock = INVALID_SOCKET;
212+
}
212213

213-
if (mResolved.empty()) {
214-
PLOG_WARNING << "Connection to " << mHostname << ":" << mService << " failed";
215-
changeState(State::Failed);
216-
return;
217-
}
214+
if (mResolved.empty()) {
215+
PLOG_WARNING << "Connection to " << mHostname << ":" << mService << " failed";
216+
changeState(State::Failed);
217+
return;
218+
}
218219

219-
try {
220220
auto [addr, addrlen] = mResolved.front();
221221
mResolved.pop_front();
222222

0 commit comments

Comments
 (0)