Jacek Caban : wininet: Directly return error status from NETCON_recv.
Alexandre Julliard
julliard at winehq.org
Tue Dec 1 09:19:41 CST 2009
Module: wine
Branch: master
Commit: 358e7b7c8aa12b6ba7db0dfb8af5edfb2174bfea
URL: http://source.winehq.org/git/wine.git/?a=commit;h=358e7b7c8aa12b6ba7db0dfb8af5edfb2174bfea
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Nov 30 19:59:40 2009 +0100
wininet: Directly return error status from NETCON_recv.
---
dlls/wininet/http.c | 10 +++++++---
dlls/wininet/internet.h | 2 +-
dlls/wininet/netconnection.c | 17 ++++++-----------
3 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index e4b6f1c..2ab2d37 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -2018,6 +2018,7 @@ static DWORD HTTPREQ_SetOption(object_header_t *hdr, DWORD option, void *buffer,
/* read some more data into the read buffer (the read section must be held) */
static BOOL read_more_data( http_request_t *req, int maxlen )
{
+ DWORD res;
int len;
if (req->read_pos)
@@ -2030,9 +2031,12 @@ static BOOL read_more_data( http_request_t *req, int maxlen )
if (maxlen == -1) maxlen = sizeof(req->read_buf);
- if(!NETCON_recv( &req->netConnection, req->read_buf + req->read_size,
- maxlen - req->read_size, 0, &len ))
+ res = NETCON_recv( &req->netConnection, req->read_buf + req->read_size,
+ maxlen - req->read_size, 0, &len );
+ if(res != ERROR_SUCCESS) {
+ INTERNET_SetLastError(res);
return FALSE;
+ }
req->read_size += len;
return TRUE;
@@ -2304,7 +2308,7 @@ static DWORD HTTPREQ_Read(http_request_t *req, void *buffer, DWORD size, DWORD *
if (size > bytes_read && (!bytes_read || sync)) {
if (NETCON_recv( &req->netConnection, (char *)buffer + bytes_read, size - bytes_read,
- sync ? MSG_WAITALL : 0, &len))
+ sync ? MSG_WAITALL : 0, &len) == ERROR_SUCCESS)
bytes_read += len;
/* always return success, even if the network layer returns an error */
}
diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h
index 04a4a65..75cd676 100644
--- a/dlls/wininet/internet.h
+++ b/dlls/wininet/internet.h
@@ -438,7 +438,7 @@ DWORD NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *s
DWORD NETCON_secure_connect(WININET_NETCONNECTION *connection, LPCWSTR hostname);
DWORD NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len, int flags,
int *sent /* out */);
-BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
+DWORD NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
int *recvd /* out */);
BOOL NETCON_query_data_available(WININET_NETCONNECTION *connection, DWORD *available);
LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection);
diff --git a/dlls/wininet/netconnection.c b/dlls/wininet/netconnection.c
index 36599e9..013789b 100644
--- a/dlls/wininet/netconnection.c
+++ b/dlls/wininet/netconnection.c
@@ -584,30 +584,25 @@ DWORD NETCON_send(WININET_NETCONNECTION *connection, const void *msg, size_t len
* Basically calls 'recv()' unless we should use SSL
* number of chars received is put in *recvd
*/
-BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
+DWORD NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int flags,
int *recvd /* out */)
{
*recvd = 0;
- if (!NETCON_connected(connection)) return FALSE;
+ if (!NETCON_connected(connection)) return ERROR_INTERNET_CONNECTION_ABORTED;
if (!len)
- return TRUE;
+ return ERROR_SUCCESS;
if (!connection->useSSL)
{
*recvd = recv(connection->socketFD, buf, len, flags);
- if (*recvd == -1)
- {
- INTERNET_SetLastError(sock_get_error(errno));
- return FALSE;
- }
- return TRUE;
+ return *recvd == -1 ? sock_get_error(errno) : ERROR_SUCCESS;
}
else
{
#ifdef SONAME_LIBSSL
*recvd = pSSL_read(connection->ssl_s, buf, len);
- return *recvd > 0 || !len;
+ return *recvd > 0 ? ERROR_SUCCESS : ERROR_INTERNET_CONNECTION_ABORTED;
#else
- return FALSE;
+ return ERROR_NOT_SUPPORTED;
#endif
}
}
More information about the wine-cvs
mailing list