Don't call poll if no sockets

This commit is contained in:
Ian Craggs 2022-02-08 15:17:19 +00:00
parent 60bf17c36e
commit 33880dff72
1 changed files with 6 additions and 0 deletions

View File

@ -294,6 +294,12 @@ SOCKET Socket_getReadySocket(int more_work, int timeout, mutex_type mutex, int*
}
memcpy(mod_s.saved.fds, mod_s.fds, mod_s.nfds * sizeof(struct pollfd));
if (mod_s.saved.nfds == 0)
{
sock = 0;
goto exit; /* no work to do */
}
/* Prevent performance issue by unlocking the socket_mutex while waiting for a ready socket. */
Thread_unlock_mutex(mutex);
*rc = poll(mod_s.saved.fds, mod_s.saved.nfds, timeout_ms);