From 53f8d78e575b20cacdcfccc304388e12c2f94fe3 Mon Sep 17 00:00:00 2001 From: Bruno Jesus <00cpxxx@gmail.com> Date: Sun, 15 Jun 2014 21:16:41 -0300 Subject: [PATCH] winhttp: Use a helper to receive data and take care of EINTR. --- dlls/winhttp/net.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/dlls/winhttp/net.c b/dlls/winhttp/net.c index c7ff0350f3a..b77c706d330 100644 --- a/dlls/winhttp/net.c +++ b/dlls/winhttp/net.c @@ -150,6 +150,17 @@ static int sock_send(int fd, const void *msg, size_t len, int flags) return ret; } +static int sock_recv(int fd, void *msg, size_t len, int flags) +{ + int ret; + do + { + ret = recv(fd, msg, len, flags); + } + while(ret == -1 && errno == EINTR); + return ret; +} + static DWORD netconn_verify_cert( PCCERT_CONTEXT cert, WCHAR *server, DWORD security_flags ) { HCERTSTORE store = cert->hCertStore; @@ -453,7 +464,7 @@ BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname ) read_buf_size += 1024; } - size = recv(conn->socket, read_buf+in_bufs[0].cbBuffer, read_buf_size-in_bufs[0].cbBuffer, 0); + size = sock_recv(conn->socket, read_buf+in_bufs[0].cbBuffer, read_buf_size-in_bufs[0].cbBuffer, 0); if(size < 1) { WARN("recv error\n"); status = ERROR_WINHTTP_SECURE_CHANNEL_ERROR; @@ -591,7 +602,7 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, SIZE_T * heap_free(conn->extra_buf); conn->extra_buf = NULL; }else { - buf_len = recv(conn->socket, conn->ssl_buf+conn->extra_len, ssl_buf_size-conn->extra_len, 0); + buf_len = sock_recv(conn->socket, conn->ssl_buf+conn->extra_len, ssl_buf_size-conn->extra_len, 0); if(buf_len < 0) { WARN("recv failed\n"); return FALSE; @@ -623,7 +634,7 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, SIZE_T * case SEC_E_INCOMPLETE_MESSAGE: assert(buf_len < ssl_buf_size); - size = recv(conn->socket, conn->ssl_buf+buf_len, ssl_buf_size-buf_len, 0); + size = sock_recv(conn->socket, conn->ssl_buf+buf_len, ssl_buf_size-buf_len, 0); if(size < 1) return FALSE; @@ -716,7 +727,7 @@ BOOL netconn_recv( netconn_t *conn, void *buf, size_t len, int flags, int *recvd *recvd = size; return TRUE; } - if ((*recvd = recv( conn->socket, buf, len, flags )) == -1) + if ((*recvd = sock_recv( conn->socket, buf, len, flags )) == -1) { set_last_error( sock_get_error( errno ) ); return FALSE;