[MSAFD] Don't update shared state on close if we still have active references to...
authorPeter Hater <7element@mail.bg>
Fri, 26 May 2017 15:27:45 +0000 (15:27 +0000)
committerPeter Hater <7element@mail.bg>
Fri, 26 May 2017 15:27:45 +0000 (15:27 +0000)
svn path=/trunk/; revision=74673

reactos/dll/win32/msafd/misc/dllmain.c

index 7bd45bf..747299e 100644 (file)
@@ -677,15 +677,16 @@ WSPCloseSocket(IN SOCKET Handle,
         if (lpErrno) *lpErrno = WSAENOTSOCK;
         return SOCKET_ERROR;
     }
-    /* Set the state to close */
-    OldState = Socket->SharedData->State;
-    Socket->SharedData->State = SocketClosed;
 
     /* Decrement reference count on SharedData */
     References = InterlockedDecrement(&Socket->SharedData->RefCount);
     if (References)
         goto ok;
 
+    /* Set the state to close */
+    OldState = Socket->SharedData->State;
+    Socket->SharedData->State = SocketClosed;
+
     /* If SO_LINGER is ON and the Socket is connected, we need to disconnect */
     /* FIXME: Should we do this on Datagram Sockets too? */
     if ((OldState == SocketConnected) && (Socket->SharedData->LingerData.l_onoff))