diff options
Diffstat (limited to 'tests/server/sockfilt.c')
| -rw-r--r-- | tests/server/sockfilt.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index 84c72f96..6b3758c9 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -75,7 +75,7 @@ * structured and well behaved manner to achieve proper program cleanup and * termination. * - * Even with the above mechanism implemented it is worthwile to note that + * Even with the above mechanism implemented it is worthwhile to note that * other signals might still be received, or that there might be systems on * which it is not possible to trap and ignore some of the above signals. * This implies that for increased portability and reliability the program @@ -676,7 +676,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, } /* allocate internal array for the internal event handles */ - handles = calloc(nfds, sizeof(HANDLE)); + handles = calloc(nfds + 1, sizeof(HANDLE)); if(handles == NULL) { CloseHandle(abort); CloseHandle(mutex); @@ -687,7 +687,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, /* loop over the handles in the input descriptor sets */ nfd = 0; /* number of handled file descriptors */ - nth = 0; /* number of interal waiting threads */ + nth = 0; /* number of internal waiting threads */ nws = 0; /* number of handled WINSOCK sockets */ for(fd = 0; fd < nfds; fd++) { wsasock = curlx_sitosk(fd); @@ -785,8 +785,18 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, } } + /* wait on the number of handles */ + wait = nfd; + + /* make sure we stop waiting on exit signal event */ + if(exit_event) { + /* we allocated handles nfds + 1 for this */ + handles[nfd] = exit_event; + wait += 1; + } + /* wait for one of the internal handles to trigger */ - wait = WaitForMultipleObjectsEx(nfd, handles, FALSE, timeout_ms, FALSE); + wait = WaitForMultipleObjectsEx(wait, handles, FALSE, timeout_ms, FALSE); /* wait for internal mutex to lock event handling in threads */ WaitForSingleObjectEx(mutex, INFINITE, FALSE); |
