Fixed #5889: Only add descriptors wanted to select
authorArmin Novak <armin.novak@thincast.com>
Tue, 18 Feb 2020 10:54:28 +0000 (11:54 +0100)
committerakallabeth <akallabeth@users.noreply.github.com>
Tue, 18 Feb 2020 13:33:45 +0000 (14:33 +0100)
winpr/libwinpr/synch/wait.c

index f4362ac..0b529f0 100644 (file)
@@ -415,14 +415,18 @@ DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE* lpHandles, BOOL bWaitAl
                        pollfds[polled].events = handle_mode_to_pollevent(Object->Mode);
                        pollfds[polled].revents = 0;
 #else
-                       FD_SET(fd, &rfds);
-                       FD_SET(fd, &wfds);
 
                        if (Object->Mode & WINPR_FD_READ)
+                       {
+                               FD_SET(fd, &rfds);
                                prfds = &rfds;
+                       }
 
                        if (Object->Mode & WINPR_FD_WRITE)
+                       {
+                               FD_SET(fd, &wfds);
                                pwfds = &wfds;
+                       }
 
                        if (fd > maxfd)
                                maxfd = fd;