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

This commit is contained in:
Bruno Jesus 2014-05-29 21:20:14 -03:00 committed by Alexandre Julliard
parent 3c16044410
commit 1b8d8ef372
3 changed files with 19 additions and 7 deletions

View File

@ -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)
{

View File

@ -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);

View File

@ -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;