[1/2] winhttp: Use a helper to send data and take care of EINTR
Bruno Jesus
00cpxxx at gmail.com
Sun Jun 15 19:16:25 CDT 2014
-------------- next part --------------
---
dlls/winhttp/net.c | 17 ++++++++++++++---
dlls/winhttp/winhttp_private.h | 1 +
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/dlls/winhttp/net.c b/dlls/winhttp/net.c
index b751bf0..d1063f6 100644
--- a/dlls/winhttp/net.c
+++ b/dlls/winhttp/net.c
@@ -403,7 +403,7 @@ BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname )
TRACE("sending %u bytes\n", out_buf.cbBuffer);
- size = send(conn->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0);
+ size = sock_send(conn->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0);
if(size != out_buf.cbBuffer) {
ERR("send failed\n");
res = ERROR_WINHTTP_SECURE_CHANNEL_ERROR;
@@ -524,7 +524,7 @@ static BOOL send_ssl_chunk(netconn_t *conn, const void *msg, size_t size)
return FALSE;
}
- if(send(conn->socket, conn->ssl_buf, bufs[0].cbBuffer+bufs[1].cbBuffer+bufs[2].cbBuffer, 0) < 1) {
+ if(sock_send(conn->socket, conn->ssl_buf, bufs[0].cbBuffer+bufs[1].cbBuffer+bufs[2].cbBuffer, 0) < 1) {
WARN("send failed\n");
return FALSE;
}
@@ -554,7 +554,7 @@ BOOL netconn_send( netconn_t *conn, const void *msg, size_t len, int *sent )
return TRUE;
}
- if ((*sent = send( conn->socket, msg, len, 0 )) == -1)
+ if ((*sent = sock_send( conn->socket, msg, len, 0 )) == -1)
{
set_last_error( sock_get_error( errno ) );
return FALSE;
@@ -748,6 +748,17 @@ DWORD netconn_set_timeout( netconn_t *netconn, BOOL send, int value )
return ERROR_SUCCESS;
}
+int sock_send(int fd, const void *msg, size_t len, int flags)
+{
+ int ret;
+ do
+ {
+ ret = send(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 8f26704..4ef91d4 100644
--- a/dlls/winhttp/winhttp_private.h
+++ b/dlls/winhttp/winhttp_private.h
@@ -274,6 +274,7 @@ BOOL netconn_send( netconn_t *, const void *, size_t, int * ) DECLSPEC_HIDDEN;
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;
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