From: Sebastian Lackner Subject: [3/3] ws2_32: Avoid race-conditions of async WSARecv() operations with write watches. Message-Id: <5507B0F0.5050207@fds-team.de> Date: Tue, 17 Mar 2015 05:43:28 +0100 --- dlls/ws2_32/socket.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) From 545be8e324198667ea621d607dd56b1b3eab5b2a Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Fri, 21 Nov 2014 12:22:46 +0100 Subject: ws2_32: Avoid race-conditions of async WSARecv() operations with write watches. --- dlls/ws2_32/socket.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 960556d..360d9ee 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -1972,7 +1972,24 @@ static int WS2_recv( int fd, struct ws2_async *wsa ) while ((n = recvmsg(fd, &hdr, wsa->flags)) == -1) { - if (errno != EINTR) + if (errno == EFAULT) + { + unsigned int i; + int loc_errno = errno; + + for (i = wsa->first_iovec; i < wsa->n_iovecs; i++) + { + struct iovec *iov = &wsa->iovec[i]; + if (wine_uninterrupted_write_memory( iov->iov_base, NULL, iov->iov_len ) < iov->iov_len) + { + errno = loc_errno; + return -1; + } + } + + /* page is writeable, try again */ + } + else if (errno != EINTR) return -1; } -- 2.3.2