Commit 1b8d8ef3 authored by Bruno Jesus's avatar Bruno Jesus Committed by Alexandre Julliard

wininet: Use a helper to send data and take care of EINTR.

parent 3c160444
...@@ -1220,7 +1220,7 @@ static DWORD FTPFILE_WriteFile(object_header_t *hdr, const void *buffer, DWORD s ...@@ -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; ftp_file_t *lpwh = (ftp_file_t*) hdr;
int res; int res;
res = send(lpwh->nDataSocket, buffer, size, 0); res = sock_send(lpwh->nDataSocket, buffer, size, 0);
*written = res>0 ? res : 0; *written = res>0 ? res : 0;
return res >= 0 ? ERROR_SUCCESS : sock_get_error(errno); return res >= 0 ? ERROR_SUCCESS : sock_get_error(errno);
...@@ -2316,7 +2316,7 @@ BOOL WINAPI FtpCommandW( HINTERNET hConnect, BOOL fExpectResponse, DWORD dwFlags ...@@ -2316,7 +2316,7 @@ BOOL WINAPI FtpCommandW( HINTERNET hConnect, BOOL fExpectResponse, DWORD dwFlags
TRACE("Sending (%s) len(%d)\n", cmd, len); TRACE("Sending (%s) len(%d)\n", cmd, len);
while ((nBytesSent < len) && (nRC != -1)) 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) if (nRC != -1)
{ {
nBytesSent += nRC; nBytesSent += nRC;
...@@ -2683,7 +2683,7 @@ static BOOL FTP_SendCommandA(INT nSocket, FTP_COMMAND ftpCmd, LPCSTR lpszParam, ...@@ -2683,7 +2683,7 @@ static BOOL FTP_SendCommandA(INT nSocket, FTP_COMMAND ftpCmd, LPCSTR lpszParam,
TRACE("Sending (%s) len(%d)\n", buf, len); TRACE("Sending (%s) len(%d)\n", buf, len);
while((nBytesSent < len) && (nRC != -1)) while((nBytesSent < len) && (nRC != -1))
{ {
nRC = send(nSocket, buf+nBytesSent, len - nBytesSent, 0); nRC = sock_send(nSocket, buf+nBytesSent, len - nBytesSent, 0);
nBytesSent += nRC; nBytesSent += nRC;
} }
heap_free(buf); heap_free(buf);
...@@ -3263,7 +3263,7 @@ static BOOL FTP_SendData(ftp_session_t *lpwfs, INT nDataSocket, HANDLE hFile) ...@@ -3263,7 +3263,7 @@ static BOOL FTP_SendData(ftp_session_t *lpwfs, INT nDataSocket, HANDLE hFile)
nLen = DATA_PACKET_SIZE < nBytesToSend ? nLen = DATA_PACKET_SIZE < nBytesToSend ?
DATA_PACKET_SIZE : nBytesToSend; DATA_PACKET_SIZE : nBytesToSend;
nRC = send(nDataSocket, lpszBuffer, nLen, 0); nRC = sock_send(nDataSocket, lpszBuffer, nLen, 0);
if (nRC != -1) if (nRC != -1)
{ {
......
...@@ -457,6 +457,7 @@ LPCVOID NETCON_GetCert(netconn_t *connection) DECLSPEC_HIDDEN; ...@@ -457,6 +457,7 @@ LPCVOID NETCON_GetCert(netconn_t *connection) DECLSPEC_HIDDEN;
int NETCON_GetCipherStrength(netconn_t*) DECLSPEC_HIDDEN; int NETCON_GetCipherStrength(netconn_t*) DECLSPEC_HIDDEN;
DWORD NETCON_set_timeout(netconn_t *connection, BOOL send, DWORD value) DECLSPEC_HIDDEN; DWORD NETCON_set_timeout(netconn_t *connection, BOOL send, DWORD value) DECLSPEC_HIDDEN;
int sock_get_error(int) 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); server_t *get_server(const WCHAR*,INTERNET_PORT,BOOL,BOOL);
......
...@@ -496,6 +496,17 @@ int sock_get_error( int err ) ...@@ -496,6 +496,17 @@ int sock_get_error( int err )
return 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) static void set_socket_blocking(int socket, blocking_mode_t mode)
{ {
#if defined(__MINGW32__) || defined (_MSC_VER) #if defined(__MINGW32__) || defined (_MSC_VER)
...@@ -546,7 +557,7 @@ static DWORD netcon_secure_connect_setup(netconn_t *connection, BOOL compat_mode ...@@ -546,7 +557,7 @@ static DWORD netcon_secure_connect_setup(netconn_t *connection, BOOL compat_mode
TRACE("sending %u bytes\n", out_buf.cbBuffer); 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) { if(size != out_buf.cbBuffer) {
ERR("send failed\n"); ERR("send failed\n");
status = ERROR_INTERNET_SECURITY_CHANNEL_ERROR; status = ERROR_INTERNET_SECURITY_CHANNEL_ERROR;
...@@ -718,7 +729,7 @@ static BOOL send_ssl_chunk(netconn_t *conn, const void *msg, size_t size) ...@@ -718,7 +729,7 @@ static BOOL send_ssl_chunk(netconn_t *conn, const void *msg, size_t size)
return FALSE; 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"); WARN("send failed\n");
return FALSE; return FALSE;
} }
...@@ -736,7 +747,7 @@ DWORD NETCON_send(netconn_t *connection, const void *msg, size_t len, int flags, ...@@ -736,7 +747,7 @@ DWORD NETCON_send(netconn_t *connection, const void *msg, size_t len, int flags,
{ {
if(!connection->secure) if(!connection->secure)
{ {
*sent = send(connection->socket, msg, len, flags); *sent = sock_send(connection->socket, msg, len, flags);
if (*sent == -1) if (*sent == -1)
return sock_get_error(errno); return sock_get_error(errno);
return ERROR_SUCCESS; return ERROR_SUCCESS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment