Module: wine Branch: master Commit: 0d2817b161e7c363c1fab523b6645002e980597a URL: http://source.winehq.org/git/wine.git/?a=commit;h=0d2817b161e7c363c1fab523b6...
Author: Sebastian Lackner sebastian@fds-team.de Date: Thu Apr 30 05:43:26 2015 +0200
ws2_32: Properly handle closing sockets during a select call.
Based on a patch by Bruno Jesus.
---
dlls/ws2_32/socket.c | 13 ++++++++++++- dlls/ws2_32/tests/sock.c | 1 - 2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index ef43186..10bfd9d 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -4773,7 +4773,18 @@ static void release_poll_fds( const WS_fd_set *readfds, const WS_fd_set *writefd if (exceptfds) { for (i = 0; i < exceptfds->fd_count; i++, j++) - if (fds[j].fd != -1) release_sock_fd( exceptfds->fd_array[i], fds[j].fd ); + { + if (fds[j].fd == -1) continue; + release_sock_fd( exceptfds->fd_array[i], fds[j].fd ); + if (fds[j].revents & POLLHUP) + { + int fd = get_sock_fd( exceptfds->fd_array[i], 0, NULL ); + if (fd != -1) + release_sock_fd( exceptfds->fd_array[i], fd ); + else + fds[j].revents = 0; + } + } } }
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index f31539f..d67a47d 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -3834,7 +3834,6 @@ todo_wine FD_ZERO_ALL(); FD_SET_ALL(fdWrite); ret = select(0, &readfds, NULL, &exceptfds, &select_timeout); -todo_wine ok(ret == 1, "expected 1, got %d\n", ret); ok(FD_ISSET(fdWrite, &readfds), "fdWrite socket is not in the set\n"); WaitForSingleObject (thread_handle, 1000);