Module: wine Branch: master Commit: 6fe55462107b4dcc31f919296a6e5870dcc881a3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=6fe55462107b4dcc31f919296a...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Jun 18 13:28:24 2015 +0200
wininet: Get rid of unneeded MSG_WAITALL support in NETCON_recv.
---
dlls/wininet/http.c | 11 +++++------ dlls/wininet/internet.h | 2 +- dlls/wininet/netconnection.c | 33 +++++++++------------------------ 3 files changed, 15 insertions(+), 31 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index f4f67cb..42654a2 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -2513,7 +2513,7 @@ static DWORD read_more_data( http_request_t *req, int maxlen ) if (maxlen == -1) maxlen = sizeof(req->read_buf);
res = NETCON_recv( req->netconn, req->read_buf + req->read_size, - maxlen - req->read_size, BLOCKING_ALLOW, &len ); + maxlen - req->read_size, TRUE, &len ); if(res == ERROR_SUCCESS) req->read_size += len;
@@ -2664,8 +2664,7 @@ static DWORD netconn_read(data_stream_t *stream, http_request_t *req, BYTE *buf, size = min(size, netconn_stream->content_length-netconn_stream->content_read);
if(size && is_valid_netconn(req->netconn)) { - while((res = NETCON_recv(req->netconn, buf+ret, size-ret, - blocking_mode == BLOCKING_WAITALL ? BLOCKING_ALLOW : blocking_mode, &len)) == ERROR_SUCCESS) { + while((res = NETCON_recv(req->netconn, buf+ret, size-ret, blocking_mode != BLOCKING_DISALLOW, &len)) == ERROR_SUCCESS) { if(!len) { netconn_stream->content_length = netconn_stream->content_read; break; @@ -2695,7 +2694,7 @@ static BOOL netconn_drain_content(data_stream_t *stream, http_request_t *req) return TRUE;
do { - if(NETCON_recv(req->netconn, buf, sizeof(buf), BLOCKING_DISALLOW, &len) != ERROR_SUCCESS) + if(NETCON_recv(req->netconn, buf, sizeof(buf), FALSE, &len) != ERROR_SUCCESS) return FALSE;
netconn_stream->content_read += len; @@ -2735,7 +2734,7 @@ static DWORD read_more_chunked_data(chunked_stream_t *stream, http_request_t *re if (maxlen == -1) maxlen = sizeof(stream->buf);
res = NETCON_recv( req->netconn, stream->buf + stream->buf_size, - maxlen - stream->buf_size, BLOCKING_ALLOW, &len ); + maxlen - stream->buf_size, TRUE, &len ); if(res == ERROR_SUCCESS) stream->buf_size += len;
@@ -2871,7 +2870,7 @@ static DWORD chunked_read(data_stream_t *stream, http_request_t *req, BYTE *buf, break; }
- res = NETCON_recv(req->netconn, (char *)buf+ret_read, read_bytes, BLOCKING_ALLOW, (int*)&read_bytes); + res = NETCON_recv(req->netconn, (char *)buf+ret_read, read_bytes, TRUE, (int*)&read_bytes); if(res != ERROR_SUCCESS) break; } diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h index 40951b6..955c7c5 100644 --- a/dlls/wininet/internet.h +++ b/dlls/wininet/internet.h @@ -427,7 +427,7 @@ void NETCON_unload(void) DECLSPEC_HIDDEN; DWORD NETCON_secure_connect(netconn_t*,server_t*) DECLSPEC_HIDDEN; DWORD NETCON_send(netconn_t *connection, const void *msg, size_t len, int flags, int *sent /* out */) DECLSPEC_HIDDEN; -DWORD NETCON_recv(netconn_t*,void*,size_t,blocking_mode_t,int*) DECLSPEC_HIDDEN; +DWORD NETCON_recv(netconn_t*,void*,size_t,BOOL,int*) DECLSPEC_HIDDEN; BOOL NETCON_query_data_available(netconn_t *connection, DWORD *available) DECLSPEC_HIDDEN; BOOL NETCON_is_alive(netconn_t*) DECLSPEC_HIDDEN; LPCVOID NETCON_GetCert(netconn_t *connection) DECLSPEC_HIDDEN; diff --git a/dlls/wininet/netconnection.c b/dlls/wininet/netconnection.c index 9f64cb9..e82dd30 100644 --- a/dlls/wininet/netconnection.c +++ b/dlls/wininet/netconnection.c @@ -731,6 +731,7 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, blocking *ret_size = buf_len;
if(!buf_len) { + TRACE("EOF\n"); *eof = TRUE; return ERROR_SUCCESS; } @@ -817,7 +818,7 @@ static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, blocking * Basically calls 'recv()' unless we should use SSL * number of chars received is put in *recvd */ -DWORD NETCON_recv(netconn_t *connection, void *buf, size_t len, blocking_mode_t mode, int *recvd) +DWORD NETCON_recv(netconn_t *connection, void *buf, size_t len, BOOL blocking, int *recvd) { *recvd = 0; if (!len) @@ -825,18 +826,13 @@ DWORD NETCON_recv(netconn_t *connection, void *buf, size_t len, blocking_mode_t
if (!connection->secure) { - int flags = 0; - - if(mode == BLOCKING_WAITALL) - flags = MSG_WAITALL; - - set_socket_blocking(connection->socket, mode); - *recvd = sock_recv(connection->socket, buf, len, flags); + set_socket_blocking(connection->socket, blocking ? BLOCKING_ALLOW : BLOCKING_DISALLOW); + *recvd = sock_recv(connection->socket, buf, len, 0); return *recvd == -1 ? WSAGetLastError() : ERROR_SUCCESS; } else { - SIZE_T size = 0, cread; + SIZE_T size = 0; BOOL eof; DWORD res;
@@ -850,17 +846,13 @@ DWORD NETCON_recv(netconn_t *connection, void *buf, size_t len, blocking_mode_t heap_free(connection->peek_msg_mem); connection->peek_msg_mem = connection->peek_msg = NULL; } - /* check if we have enough data from the peek buffer */ - if(mode != BLOCKING_WAITALL || size == len) { - *recvd = size; - return ERROR_SUCCESS; - }
- mode = BLOCKING_DISALLOW; + *recvd = size; + return ERROR_SUCCESS; }
do { - res = read_ssl_chunk(connection, (BYTE*)buf+size, len-size, mode, &cread, &eof); + res = read_ssl_chunk(connection, (BYTE*)buf+size, len-size, blocking ? BLOCKING_ALLOW : BLOCKING_DISALLOW, &size, &eof); if(res != ERROR_SUCCESS) { if(res == WSAEWOULDBLOCK) { if(size) @@ -870,14 +862,7 @@ DWORD NETCON_recv(netconn_t *connection, void *buf, size_t len, blocking_mode_t } break; } - - if(eof) { - TRACE("EOF\n"); - break; - } - - size += cread; - }while(!size || (mode == BLOCKING_WAITALL && size < len)); + }while(!size && !eof);
TRACE("received %ld bytes\n", size); *recvd = size;