From ec353945708de5569484a68509c89232556ab2e6 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Tue, 13 Dec 2016 10:33:35 +0100 Subject: [PATCH] winhttp: Handle EINTR from connect and poll. Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/winhttp/net.c | 49 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/dlls/winhttp/net.c b/dlls/winhttp/net.c index 7213dd92a27..1cabec0cb9c 100644 --- a/dlls/winhttp/net.c +++ b/dlls/winhttp/net.c @@ -353,7 +353,7 @@ BOOL netconn_close( netconn_t *conn ) BOOL netconn_connect( netconn_t *conn, const struct sockaddr *sockaddr, unsigned int addr_len, int timeout ) { BOOL ret = FALSE; - int res = 0; + int res; ULONG state; if (timeout > 0) @@ -361,23 +361,42 @@ BOOL netconn_connect( netconn_t *conn, const struct sockaddr *sockaddr, unsigned state = 1; ioctlsocket( conn->socket, FIONBIO, &state ); } - if (connect( conn->socket, sockaddr, addr_len ) < 0) - { - res = sock_get_error( errno ); - if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS) - { - struct pollfd pfd; - pfd.fd = conn->socket; - pfd.events = POLLOUT; - if (poll( &pfd, 1, timeout ) > 0) - ret = TRUE; - else - res = sock_get_error( errno ); + for (;;) + { + res = 0; + if (connect( conn->socket, sockaddr, addr_len ) < 0) + { + res = sock_get_error( errno ); + if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS) + { + struct pollfd pfd; + + pfd.fd = conn->socket; + pfd.events = POLLOUT; + for (;;) + { + res = 0; + if (poll( &pfd, 1, timeout ) > 0) + { + ret = TRUE; + break; + } + else + { + res = sock_get_error( errno ); + if (res != WSAEINTR) break; + } + } + } + if (res != WSAEINTR) break; + } + else + { + ret = TRUE; + break; } } - else - ret = TRUE; if (timeout > 0) { state = 0;