Fix hang on Windows when multiple --client args are present
authorjrizzo <james.rizzo@broadcom.com>
Tue, 15 Apr 2025 17:57:20 +0000 (11:57 -0600)
committerjrizzo <james.rizzo@broadcom.com>
Tue, 15 Apr 2025 17:58:48 +0000 (11:58 -0600)
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 <james.rizzo@broadcom.com>
os/windows/posix.c

index 2ce18b8bdb8dae781f52dcae15d4393bd184d34f..e3abf383e929333056c1f15a2cdbad3234f44d68 100644 (file)
@@ -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);