Skip to content

Commit 0034196

Browse files
committed
Fix potential deadlock in sockets_del()
Fixes Coverity CID 895679 sockets_del() acquires ss->mutex so we must release it before calling
1 parent 1d68d26 commit 0034196

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/socketworks.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,10 +889,12 @@ void *select_and_execute(void *arg) {
889889
int rv;
890890
if (ss->sock == SOCK_TIMEOUT)
891891
ss->rtime = getTick();
892-
std::lock_guard<SMutex> lock(ss->mutex);
892+
std::unique_lock<SMutex> lock(ss->mutex);
893893
rv = ss->timeout(ss);
894-
if (rv)
894+
if (rv) {
895+
lock.unlock();
895896
sockets_del(i);
897+
}
896898
} else
897899
sockets_del(i);
898900
}

0 commit comments

Comments
 (0)