From 6c6435011c6cdceb9c3e54f00a2da933ea16e463 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 13 Mar 2016 23:00:49 +0100
Subject: ws2_32: Add semi-stub for DisconnectEx.

---
 dlls/ws2_32/socket.c     | 21 ++++++++++++++++++++-
 dlls/ws2_32/tests/sock.c |  4 ++--
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index f62c9cd..0fea98a 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -3552,6 +3552,24 @@ connection_success:
     return TRUE;
 }
 
+/***********************************************************************
+ *             DisconnectEx
+ */
+static BOOL WINAPI WS2_DisconnectEx( SOCKET s, LPOVERLAPPED ov, DWORD flags, DWORD reserved )
+{
+    FIXME( "socket %04lx, ov %p, flags 0x%x, reserved 0x%x: semi-stub\n", s, ov, flags, reserved );
+
+    if (flags & TF_REUSE_SOCKET)
+        FIXME( "Reusing sockets is not supported, problems ahead.\n" );
+
+    if (ov)
+    {
+        ov->Internal = STATUS_PENDING;
+        ov->InternalHigh = 0;
+    }
+
+    return !WS_shutdown( s, SD_BOTH );
+}
 
 /***********************************************************************
  *		getpeername		(WS2_32.5)
@@ -4767,7 +4785,8 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
         }
         else if ( IsEqualGUID(&disconnectex_guid, in_buff) )
         {
-            FIXME("SIO_GET_EXTENSION_FUNCTION_POINTER: unimplemented DisconnectEx\n");
+            *(LPFN_DISCONNECTEX *)out_buff = WS2_DisconnectEx;
+            break;
         }
         else if ( IsEqualGUID(&acceptex_guid, in_buff) )
         {
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 80173ed..a982e1e 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -7828,7 +7828,7 @@ static void test_DisconnectEx(void)
                     &pDisconnectEx, sizeof(pDisconnectEx), &num_bytes, NULL, NULL);
     if (iret)
     {
-        skip("WSAIoctl failed to get DisconnectEx, error %d\n", WSAGetLastError());
+        win_skip("WSAIoctl failed to get DisconnectEx, error %d\n", WSAGetLastError());
         closesocket(connector);
         return;
     }
@@ -7859,7 +7859,7 @@ static void test_DisconnectEx(void)
     memset(&overlapped, 0, sizeof(overlapped));
     bret = pDisconnectEx(connector, &overlapped, 0, 0);
     ok(bret == FALSE, "DisconnectEx unexpectedly succeeded\n");
-    ok(WSAGetLastError() == WSAENOTCONN, "expected WSAENOTCONN, got %u\n", WSAGetLastError());
+    todo_wine ok(WSAGetLastError() == WSAENOTCONN, "expected WSAENOTCONN, got %u\n", WSAGetLastError());
 
     iret = connect(connector, (struct sockaddr *)&address, addrlen);
     ok(iret == 0, "failed to connect, error %d\n", WSAGetLastError());
-- 
2.7.1

