Commit 4f8fe3b1 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

winhttp: Use completion port for async send.

parent dae64e2d
......@@ -53,9 +53,20 @@ static int sock_send(int fd, const void *msg, size_t len, WSAOVERLAPPED *ovr)
BOOL netconn_wait_overlapped_result( struct netconn *conn, WSAOVERLAPPED *ovr, DWORD *len )
{
DWORD retflags;
OVERLAPPED *completion_ovr;
ULONG_PTR key;
return WSAGetOverlappedResult( conn->socket, ovr, len, TRUE, &retflags );
if (!GetQueuedCompletionStatus( conn->port, len, &key, &completion_ovr, INFINITE ))
{
WARN( "GetQueuedCompletionStatus failed, err %lu.\n", GetLastError() );
return FALSE;
}
if ((key != conn->socket && conn->socket != -1) || completion_ovr != (OVERLAPPED *)ovr)
{
ERR( "Unexpected completion key %Ix, overlapped %p.\n", key, completion_ovr );
return FALSE;
}
return TRUE;
}
static int sock_recv(int fd, void *msg, size_t len, int flags)
......@@ -279,6 +290,8 @@ void netconn_close( struct netconn *conn )
if (conn->socket != -1)
closesocket( conn->socket );
release_host( conn->host );
if (conn->port)
CloseHandle( conn->port );
free(conn);
}
......@@ -452,6 +465,12 @@ DWORD netconn_send( struct netconn *conn, const void *msg, size_t len, int *sent
{
DWORD err;
if (ovr && !conn->port)
{
if (!(conn->port = CreateIoCompletionPort( (HANDLE)(SOCKET)conn->socket, NULL, (ULONG_PTR)conn->socket, 0 )))
ERR( "Failed to create port.\n" );
}
if (conn->secure)
{
const BYTE *ptr = msg;
......
......@@ -117,6 +117,7 @@ struct netconn
char *peek_msg;
char *peek_msg_mem;
size_t peek_len;
HANDLE port;
};
struct header
......
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