Commit 904f7cfb authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

ws2_32: Copy send buffer data for async send in WS2_ConnectEx().

parent ab044d1b
......@@ -3447,14 +3447,18 @@ static BOOL WINAPI WS2_ConnectEx(SOCKET s, const struct WS_sockaddr* name, int n
else if (ret == WSAEINPROGRESS)
{
struct ws2_async *wsa;
DWORD size;
ULONG_PTR cvalue = (((ULONG_PTR)ov->hEvent & 1) == 0) ? (ULONG_PTR)ov : 0;
_enable_event(SOCKET2HANDLE(s), FD_CONNECT|FD_READ|FD_WRITE,
FD_CONNECT,
FD_WINE_CONNECTED|FD_WINE_LISTENING);
size = offsetof( struct ws2_async, iovec[1] ) + sendBufLen;
/* Indirectly call WSASend */
if (!(wsa = (struct ws2_async *)alloc_async_io( offsetof( struct ws2_async, iovec[1] ), WS2_async_send )))
if (!(wsa = (struct ws2_async *)alloc_async_io( size, WS2_async_send )))
{
SetLastError(WSAEFAULT);
}
......@@ -3473,9 +3477,12 @@ static BOOL WINAPI WS2_ConnectEx(SOCKET s, const struct WS_sockaddr* name, int n
wsa->n_iovecs = sendBuf ? 1 : 0;
wsa->first_iovec = 0;
wsa->completion_func = NULL;
wsa->iovec[0].iov_base = sendBuf;
wsa->iovec[0].iov_base = &wsa->iovec[1];
wsa->iovec[0].iov_len = sendBufLen;
if (sendBufLen)
memcpy( wsa->iovec[0].iov_base, sendBuf, sendBufLen );
status = register_async( ASYNC_TYPE_WRITE, wsa->hSocket, &wsa->io, ov->hEvent,
NULL, (void *)cvalue, iosb );
if (status != STATUS_PENDING) HeapFree(GetProcessHeap(), 0, wsa);
......
......@@ -7296,6 +7296,7 @@ static void test_ConnectEx(void)
buffer[1] = '2';
buffer[2] = '3';
bret = pConnectEx(connector, (struct sockaddr*)&address, addrlen, buffer, 3, &bytesReturned, &overlapped);
memset(buffer, 0, 3);
ok(bret == FALSE && WSAGetLastError() == ERROR_IO_PENDING, "ConnectEx failed: "
"returned %d + errno %d\n", bret, WSAGetLastError());
dwret = WaitForSingleObject(overlapped.hEvent, 15000);
......
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