[PATCH 2/2] Quickly retry sendmsg or recvmsg if errno is EAGAIN or EINTR.
mtewoodbury at gmail.com
mtewoodbury at gmail.com
Fri Feb 21 18:35:19 CST 2014
From: Max TenEyck Woodbury <max+git at mtew.isa-geek.net>
Note that this greatly improves network reliability.
---
dlls/ws2_32/socket.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 2a2c809..22f2056 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -1921,7 +1921,11 @@ static int WS2_recv( int fd, struct ws2_async *wsa )
hdr.msg_flags = 0;
#endif
- if ( (n = recvmsg(fd, &hdr, wsa->flags)) == -1 )
+ n = recvmsg(fd, &hdr, wsa->flags);
+ if (n == -1 && (errno == EINTR || errno == EAGAIN))
+ n = recvmsg(fd, &hdr, wsa->flags);
+ if (n == -1)
+
return -1;
#ifdef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS
@@ -2173,8 +2177,9 @@ static int WS2_send( int fd, struct ws2_async *wsa )
#endif
ret = sendmsg(fd, &hdr, wsa->flags);
- if (ret >= 0)
- {
+ if (ret == -1 && (errno == EINTR || errno == EAGAIN))
+ ret = sendmsg(fd, &hdr, wsa->flags); /* Try it again quickly */
+ if (ret >= 0) {
n = ret;
while (wsa->first_iovec < wsa->n_iovecs && wsa->iovec[wsa->first_iovec].iov_len <= n)
n -= wsa->iovec[wsa->first_iovec++].iov_len;
--
1.8.0.rc0.18.gf84667d
More information about the wine-patches
mailing list