From 33880dff72dbf8a331819f70f98a11eb72dee525 Mon Sep 17 00:00:00 2001 From: Ian Craggs Date: Tue, 8 Feb 2022 15:17:19 +0000 Subject: [PATCH] Don't call poll if no sockets --- src/Socket.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Socket.c b/src/Socket.c index 417ab8e5..12d70973 100644 --- a/src/Socket.c +++ b/src/Socket.c @@ -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);