[MSAFD] Don't update shared state on close if we still have active references to the socket. Checked also by ws2_32:close API test CORE-12029

svn path=/trunk/; revision=74673
This commit is contained in:
Peter Hater 2017-05-26 15:27:45 +00:00
parent 1c9d856e91
commit fb1a1ab85e

View 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))