Commit 89e1cf3d authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ws2_32: Use IOCTL_AFD_WINE_SHUTDOWN in WS2_DisconnectEx().

parent e68f41e4
......@@ -3110,23 +3110,34 @@ static BOOL WINAPI WS2_ConnectEx( SOCKET s, const struct WS_sockaddr *name, int
return !status;
}
/***********************************************************************
* DisconnectEx
*/
static BOOL WINAPI WS2_DisconnectEx( SOCKET s, LPOVERLAPPED ov, DWORD flags, DWORD reserved )
static BOOL WINAPI WS2_DisconnectEx( SOCKET s, OVERLAPPED *overlapped, DWORD flags, DWORD reserved )
{
TRACE( "socket %04lx, ov %p, flags 0x%x, reserved 0x%x\n", s, ov, flags, reserved );
IO_STATUS_BLOCK iosb, *piosb = &iosb;
void *cvalue = NULL;
int how = SD_SEND;
HANDLE event = 0;
NTSTATUS status;
TRACE( "socket %#lx, overlapped %p, flags %#x, reserved %#x\n", s, overlapped, flags, reserved );
if (flags & TF_REUSE_SOCKET)
FIXME( "Reusing socket not supported yet\n" );
if (ov)
if (overlapped)
{
ov->Internal = STATUS_PENDING;
ov->InternalHigh = 0;
piosb = (IO_STATUS_BLOCK *)overlapped;
if (!((ULONG_PTR)overlapped->hEvent & 1)) cvalue = overlapped;
event = overlapped->hEvent;
overlapped->Internal = STATUS_PENDING;
overlapped->InternalHigh = 0;
}
return !WS_shutdown( s, SD_BOTH );
status = NtDeviceIoControlFile( (HANDLE)s, event, NULL, cvalue, piosb,
IOCTL_AFD_WINE_SHUTDOWN, &how, sizeof(how), NULL, 0 );
if (!status && overlapped) status = STATUS_PENDING;
SetLastError( NtStatusToWSAError( status ) );
return !status;
}
/***********************************************************************
......
......@@ -6732,7 +6732,7 @@ static void test_DisconnectEx(void)
WSASetLastError(0xdeadbeef);
ret = pDisconnectEx(client, &overlapped, 0, 0);
ok(!ret, "expected failure\n");
todo_wine ok(WSAGetLastError() == WSAENOTCONN, "got error %u\n", WSAGetLastError());
ok(WSAGetLastError() == WSAENOTCONN, "got error %u\n", WSAGetLastError());
ret = connect(client, (struct sockaddr *)&server_addr, sizeof(server_addr));
ok(!ret, "failed to connect, error %u\n", WSAGetLastError());
......@@ -6741,18 +6741,15 @@ static void test_DisconnectEx(void)
WSASetLastError(0xdeadbeef);
ret = pDisconnectEx(client, &overlapped, 0, 0);
todo_wine ok(!ret, "expected failure\n");
todo_wine ok(WSAGetLastError() == ERROR_IO_PENDING, "got error %u\n", WSAGetLastError());
ok(!ret, "expected failure\n");
ok(WSAGetLastError() == ERROR_IO_PENDING, "got error %u\n", WSAGetLastError());
if (WSAGetLastError() == ERROR_IO_PENDING)
{
ret = WaitForSingleObject(overlapped.hEvent, 1000);
ok(!ret, "wait timed out\n");
size = 0xdeadbeef;
ret = GetOverlappedResult((HANDLE)client, &overlapped, &size, FALSE);
ok(ret, "got error %u\n", GetLastError());
ok(!size, "got size %u\n", size);
}
ret = connect(client, (struct sockaddr *)&server_addr, sizeof(server_addr));
ok(ret == -1, "expected failure\n");
......@@ -6805,8 +6802,8 @@ static void test_DisconnectEx(void)
WSASetLastError(0xdeadbeef);
ret = pDisconnectEx(client, NULL, 0, 0);
todo_wine ok(ret, "expected success\n");
todo_wine ok(!WSAGetLastError() || WSAGetLastError() == 0xdeadbeef /* < 7 */, "got error %u\n", WSAGetLastError());
ok(ret, "expected success\n");
ok(!WSAGetLastError() || WSAGetLastError() == 0xdeadbeef /* < 7 */, "got error %u\n", WSAGetLastError());
ret = connect(client, (struct sockaddr *)&server_addr, sizeof(server_addr));
ok(ret == -1, "expected failure\n");
......@@ -8552,10 +8549,9 @@ static void test_shutdown_completion_port(void)
SetLastError(0xdeadbeef);
ret = pDisconnectEx(client, &overlapped, 0, 0);
todo_wine ok(!ret, "expected failure\n");
todo_wine ok(GetLastError() == ERROR_IO_PENDING, "got error %u\n", GetLastError());
if (GetLastError() == ERROR_IO_PENDING)
{
ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_IO_PENDING, "got error %u\n", GetLastError());
ret = WaitForSingleObject(overlapped.hEvent, 1000);
ok(!ret, "wait failed\n");
......@@ -8563,7 +8559,6 @@ static void test_shutdown_completion_port(void)
ret = GetOverlappedResult((HANDLE)client, &overlapped, &size, TRUE);
ok(ret, "got error %u\n", GetLastError());
ok(!size, "got %u bytes\n", size);
}
size = 0xdeadbeef;
key = 0xdeadbeef;
......@@ -8617,10 +8612,9 @@ static void test_shutdown_completion_port(void)
SetLastError(0xdeadbeef);
ret = pDisconnectEx(client, &overlapped, 0, 0);
todo_wine ok(!ret, "expected failure\n");
todo_wine ok(GetLastError() == ERROR_IO_PENDING, "got error %u\n", GetLastError());
if (GetLastError() == ERROR_IO_PENDING)
{
ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_IO_PENDING, "got error %u\n", GetLastError());
ret = WaitForSingleObject(overlapped.hEvent, 1000);
ok(!ret, "wait failed\n");
......@@ -8628,7 +8622,6 @@ static void test_shutdown_completion_port(void)
ret = GetOverlappedResult((HANDLE)client, &overlapped, &size, TRUE);
ok(ret, "got error %u\n", GetLastError());
ok(!size, "got %u bytes\n", size);
}
ret = GetQueuedCompletionStatus(port, &size, &key, &overlapped_ptr, 0);
ok(!ret, "expected failure\n");
......
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