From b7be1e420f66a0fe2bf9b22f5a3e9da077330b41 Mon Sep 17 00:00:00 2001 From: jrizzo Date: Tue, 15 Apr 2025 11:57:20 -0600 Subject: [PATCH] Fix hang on Windows when multiple --client args are present The Windows poll function does not clear revents field before it is populated. As a result, subsequent calls to poll using the same pollfd reference return with revents set even when there is nothing available to read. This later results in a hang in recv(). Signed-off-by: James Rizzo --- os/windows/posix.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/os/windows/posix.c b/os/windows/posix.c index 2ce18b8b..e3abf383 100644 --- a/os/windows/posix.c +++ b/os/windows/posix.c @@ -899,10 +899,9 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout) FD_ZERO(&exceptfds); for (i = 0; i < nfds; i++) { - if (fds[i].fd == INVALID_SOCKET) { - fds[i].revents = 0; + fds[i].revents = 0; + if (fds[i].fd == INVALID_SOCKET) continue; - } if (fds[i].events & POLLIN) FD_SET(fds[i].fd, &readfds); -- 2.25.1