[2/2] winhttp: Use a helper to receive data and take care of EINTR

Bruno Jesus 00cpxxx at gmail.com
Sun Jun 15 19:16:41 CDT 2014


-------------- next part --------------

---
 dlls/winhttp/net.c             | 19 +++++++++++++++----
 dlls/winhttp/winhttp_private.h |  1 +
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/dlls/winhttp/net.c b/dlls/winhttp/net.c
index d1063f6..dd53ec4 100644
--- a/dlls/winhttp/net.c
+++ b/dlls/winhttp/net.c
@@ -442,7 +442,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;
@@ -580,7 +580,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;
@@ -612,7 +612,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;
 
@@ -705,7 +705,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;
@@ -759,6 +759,17 @@ int sock_send(int fd, const void *msg, size_t len, int flags)
     return ret;
 }
 
+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 resolve_hostname( const WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr *sa, socklen_t *sa_len )
 {
     char *hostname;
diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h
index 4ef91d4..dc5044e 100644
--- a/dlls/winhttp/winhttp_private.h
+++ b/dlls/winhttp/winhttp_private.h
@@ -275,6 +275,7 @@ DWORD netconn_set_timeout( netconn_t *, BOOL, int ) DECLSPEC_HIDDEN;
 const void *netconn_get_certificate( netconn_t * ) DECLSPEC_HIDDEN;
 int netconn_get_cipher_strength( netconn_t * ) DECLSPEC_HIDDEN;
 int sock_send(int fd, const void *msg, size_t len, int flags) DECLSPEC_HIDDEN;
+int sock_recv(int fd, void *msg, size_t len, int flags) DECLSPEC_HIDDEN;
 
 BOOL set_cookies( request_t *, const WCHAR * ) DECLSPEC_HIDDEN;
 BOOL add_cookie_headers( request_t * ) DECLSPEC_HIDDEN;
-- 
1.8.3.2



More information about the wine-patches mailing list