Module: wine Branch: master Commit: 1b8d8ef372cbb6b77e8c381ce4e08ac2025f768c URL: http://source.winehq.org/git/wine.git/?a=commit;h=1b8d8ef372cbb6b77e8c381ce4...
Author: Bruno Jesus 00cpxxx@gmail.com Date: Thu May 29 21:20:14 2014 -0300
wininet: Use a helper to send data and take care of EINTR.
---
dlls/wininet/ftp.c | 8 ++++---- dlls/wininet/internet.h | 1 + dlls/wininet/netconnection.c | 17 ++++++++++++++--- 3 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c index 837fcad..5576de9 100644 --- a/dlls/wininet/ftp.c +++ b/dlls/wininet/ftp.c @@ -1220,7 +1220,7 @@ static DWORD FTPFILE_WriteFile(object_header_t *hdr, const void *buffer, DWORD s ftp_file_t *lpwh = (ftp_file_t*) hdr; int res;
- res = send(lpwh->nDataSocket, buffer, size, 0); + res = sock_send(lpwh->nDataSocket, buffer, size, 0);
*written = res>0 ? res : 0; return res >= 0 ? ERROR_SUCCESS : sock_get_error(errno); @@ -2316,7 +2316,7 @@ BOOL WINAPI FtpCommandW( HINTERNET hConnect, BOOL fExpectResponse, DWORD dwFlags TRACE("Sending (%s) len(%d)\n", cmd, len); while ((nBytesSent < len) && (nRC != -1)) { - nRC = send(lpwfs->sndSocket, cmd + nBytesSent, len - nBytesSent, 0); + nRC = sock_send(lpwfs->sndSocket, cmd + nBytesSent, len - nBytesSent, 0); if (nRC != -1) { nBytesSent += nRC; @@ -2683,7 +2683,7 @@ static BOOL FTP_SendCommandA(INT nSocket, FTP_COMMAND ftpCmd, LPCSTR lpszParam, TRACE("Sending (%s) len(%d)\n", buf, len); while((nBytesSent < len) && (nRC != -1)) { - nRC = send(nSocket, buf+nBytesSent, len - nBytesSent, 0); + nRC = sock_send(nSocket, buf+nBytesSent, len - nBytesSent, 0); nBytesSent += nRC; } heap_free(buf); @@ -3263,7 +3263,7 @@ static BOOL FTP_SendData(ftp_session_t *lpwfs, INT nDataSocket, HANDLE hFile)
nLen = DATA_PACKET_SIZE < nBytesToSend ? DATA_PACKET_SIZE : nBytesToSend; - nRC = send(nDataSocket, lpszBuffer, nLen, 0); + nRC = sock_send(nDataSocket, lpszBuffer, nLen, 0);
if (nRC != -1) { diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h index a641340..87369c6 100644 --- a/dlls/wininet/internet.h +++ b/dlls/wininet/internet.h @@ -457,6 +457,7 @@ LPCVOID NETCON_GetCert(netconn_t *connection) DECLSPEC_HIDDEN; int NETCON_GetCipherStrength(netconn_t*) DECLSPEC_HIDDEN; DWORD NETCON_set_timeout(netconn_t *connection, BOOL send, DWORD value) DECLSPEC_HIDDEN; int sock_get_error(int) DECLSPEC_HIDDEN; +int sock_send(int fd, const void *msg, size_t len, int flags) DECLSPEC_HIDDEN;
server_t *get_server(const WCHAR*,INTERNET_PORT,BOOL,BOOL);
diff --git a/dlls/wininet/netconnection.c b/dlls/wininet/netconnection.c index 074229e..595dd71 100644 --- a/dlls/wininet/netconnection.c +++ b/dlls/wininet/netconnection.c @@ -496,6 +496,17 @@ int sock_get_error( int err ) return err; }
+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 void set_socket_blocking(int socket, blocking_mode_t mode) { #if defined(__MINGW32__) || defined (_MSC_VER) @@ -546,7 +557,7 @@ static DWORD netcon_secure_connect_setup(netconn_t *connection, BOOL compat_mode
TRACE("sending %u bytes\n", out_buf.cbBuffer);
- size = send(connection->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0); + size = sock_send(connection->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0); if(size != out_buf.cbBuffer) { ERR("send failed\n"); status = ERROR_INTERNET_SECURITY_CHANNEL_ERROR; @@ -718,7 +729,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; } @@ -736,7 +747,7 @@ DWORD NETCON_send(netconn_t *connection, const void *msg, size_t len, int flags, { if(!connection->secure) { - *sent = send(connection->socket, msg, len, flags); + *sent = sock_send(connection->socket, msg, len, flags); if (*sent == -1) return sock_get_error(errno); return ERROR_SUCCESS;