winhttp: Store socked address in netconn_t.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2017-07-18 00:24:59 +02:00 committed by Alexandre Julliard
parent e129023eb7
commit 3e60241677
3 changed files with 11 additions and 9 deletions

View File

@ -299,12 +299,13 @@ void netconn_unload( void )
#endif #endif
} }
netconn_t *netconn_create( int domain, int type, int protocol ) netconn_t *netconn_create( const struct sockaddr_storage *sockaddr )
{ {
netconn_t *conn; netconn_t *conn;
conn = heap_alloc_zero(sizeof(*conn)); conn = heap_alloc_zero(sizeof(*conn));
if (!conn) return NULL; if (!conn) return NULL;
if ((conn->socket = socket( domain, type, protocol )) == -1) conn->sockaddr = *sockaddr;
if ((conn->socket = socket( sockaddr->ss_family, SOCK_STREAM, 0 )) == -1)
{ {
WARN("unable to create socket (%s)\n", strerror(errno)); WARN("unable to create socket (%s)\n", strerror(errno));
set_last_error( sock_get_error( errno ) ); set_last_error( sock_get_error( errno ) );
@ -335,14 +336,14 @@ BOOL netconn_close( netconn_t *conn )
return TRUE; return TRUE;
} }
BOOL netconn_connect( netconn_t *conn, const struct sockaddr_storage *sockaddr, int timeout ) BOOL netconn_connect( netconn_t *conn, int timeout )
{ {
unsigned int addr_len; unsigned int addr_len;
BOOL ret = FALSE; BOOL ret = FALSE;
int res; int res;
ULONG state; ULONG state;
switch (sockaddr->ss_family) switch (conn->sockaddr.ss_family)
{ {
case AF_INET: case AF_INET:
addr_len = sizeof(struct sockaddr_in); addr_len = sizeof(struct sockaddr_in);
@ -363,7 +364,7 @@ BOOL netconn_connect( netconn_t *conn, const struct sockaddr_storage *sockaddr,
for (;;) for (;;)
{ {
res = 0; res = 0;
if (connect( conn->socket, (const struct sockaddr *)sockaddr, addr_len ) < 0) if (connect( conn->socket, (const struct sockaddr *)&conn->sockaddr, addr_len ) < 0)
{ {
res = sock_get_error( errno ); res = sock_get_error( errno );
if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS) if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS)

View File

@ -1021,14 +1021,14 @@ static BOOL open_connection( request_t *request )
send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, addressW, 0 ); send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, addressW, 0 );
if (!(netconn = netconn_create( connect->sockaddr.ss_family, SOCK_STREAM, 0 ))) if (!(netconn = netconn_create( &connect->sockaddr )))
{ {
heap_free( addressW ); heap_free( addressW );
return FALSE; return FALSE;
} }
netconn_set_timeout( netconn, TRUE, request->send_timeout ); netconn_set_timeout( netconn, TRUE, request->send_timeout );
netconn_set_timeout( netconn, FALSE, request->recv_timeout ); netconn_set_timeout( netconn, FALSE, request->recv_timeout );
if (!netconn_connect( netconn, &connect->sockaddr, request->connect_timeout )) if (!netconn_connect( netconn, request->connect_timeout ))
{ {
netconn_close( netconn ); netconn_close( netconn );
heap_free( addressW ); heap_free( addressW );

View File

@ -130,6 +130,7 @@ typedef struct
typedef struct typedef struct
{ {
int socket; int socket;
struct sockaddr_storage sockaddr;
BOOL secure; /* SSL active on connection? */ BOOL secure; /* SSL active on connection? */
CtxtHandle ssl_ctx; CtxtHandle ssl_ctx;
SecPkgContext_StreamSizes ssl_sizes; SecPkgContext_StreamSizes ssl_sizes;
@ -282,8 +283,8 @@ void send_callback( object_header_t *, DWORD, LPVOID, DWORD ) DECLSPEC_HIDDEN;
void close_connection( request_t * ) DECLSPEC_HIDDEN; void close_connection( request_t * ) DECLSPEC_HIDDEN;
BOOL netconn_close( netconn_t * ) DECLSPEC_HIDDEN; BOOL netconn_close( netconn_t * ) DECLSPEC_HIDDEN;
BOOL netconn_connect( netconn_t *, const struct sockaddr_storage *, int ) DECLSPEC_HIDDEN; BOOL netconn_connect( netconn_t *, int ) DECLSPEC_HIDDEN;
netconn_t *netconn_create( int, int, int ) DECLSPEC_HIDDEN; netconn_t *netconn_create( const struct sockaddr_storage * ) DECLSPEC_HIDDEN;
void netconn_unload( void ) DECLSPEC_HIDDEN; void netconn_unload( void ) DECLSPEC_HIDDEN;
ULONG netconn_query_data_available( netconn_t * ) DECLSPEC_HIDDEN; ULONG netconn_query_data_available( netconn_t * ) DECLSPEC_HIDDEN;
BOOL netconn_recv( netconn_t *, void *, size_t, int, int * ) DECLSPEC_HIDDEN; BOOL netconn_recv( netconn_t *, void *, size_t, int, int * ) DECLSPEC_HIDDEN;