Author: cgutman
Date: Thu Aug 12 22:39:24 2010
New Revision: 48526
URL:
http://svn.reactos.org/svn/reactos?rev=48526&view=rev
Log:
[MSWSOCK]
- AFD_EVENT_CLOSE also triggers on FD_CLOSE
- Fix a deadlock after calling WSPEnumNetworkEvents
- Fix a deadlock when calling WSPSend on an unbound socket
- Leave the critical section while waiting
- Firefox (and many other applications) work now
Modified:
branches/aicom-network-branch/dll/win32/mswsock/msafd/accept.c
branches/aicom-network-branch/dll/win32/mswsock/msafd/eventsel.c
branches/aicom-network-branch/dll/win32/mswsock/msafd/send.c
Modified: branches/aicom-network-branch/dll/win32/mswsock/msafd/accept.c
URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/dll/win32/…
==============================================================================
--- branches/aicom-network-branch/dll/win32/mswsock/msafd/accept.c [iso-8859-1]
(original)
+++ branches/aicom-network-branch/dll/win32/mswsock/msafd/accept.c [iso-8859-1] Thu Aug 12
22:39:24 2010
@@ -27,7 +27,7 @@
HANDLE EventObject = NULL;
ULONG AsyncEvents = 0, NetworkEvents = 0;
CHAR HelperBuffer[256];
-
+
/* Set the new state */
AcceptedSocket->SharedData.State = SocketConnected;
@@ -82,8 +82,7 @@
HelperContextSize);
if (!HelperContext)
{
- /* Unlock the socket and fail */
- LeaveCriticalSection(&Socket->Lock);
+ /* Fail */
return WSAENOBUFS;
}
}
@@ -98,9 +97,6 @@
HelperContext,
&HelperContextSize);
}
-
- /* We're done with the old socket, so we can release the lock */
- LeaveCriticalSection(&Socket->Lock);
/* Get the TDI Handles for the new socket */
ErrorCode = SockGetTdiHandles(AcceptedSocket);
@@ -311,6 +307,7 @@
NULL,
&Timeout,
lpErrno);
+
if (ReturnValue == SOCKET_ERROR)
{
/* Fail */
@@ -412,10 +409,13 @@
if (Status == STATUS_PENDING)
{
/* Wait for completion */
+ LeaveCriticalSection(&Socket->Lock);
SockWaitForSingleObject(ThreadData->EventHandle,
Handle,
NO_BLOCKING_HOOK,
NO_TIMEOUT);
+ EnterCriticalSection(&Socket->Lock);
+
/* Get new status */
Status = IoStatusBlock.Status;
}
@@ -462,10 +462,13 @@
if (Status == STATUS_PENDING)
{
/* Wait for completion */
+ LeaveCriticalSection(&Socket->Lock);
SockWaitForSingleObject(ThreadData->EventHandle,
Handle,
NO_BLOCKING_HOOK,
NO_TIMEOUT);
+ EnterCriticalSection(&Socket->Lock);
+
/* Get new status */
Status = IoStatusBlock.Status;
}
Modified: branches/aicom-network-branch/dll/win32/mswsock/msafd/eventsel.c
URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/dll/win32/…
==============================================================================
--- branches/aicom-network-branch/dll/win32/mswsock/msafd/eventsel.c [iso-8859-1]
(original)
+++ branches/aicom-network-branch/dll/win32/mswsock/msafd/eventsel.c [iso-8859-1] Thu Aug
12 22:39:24 2010
@@ -72,6 +72,7 @@
/* Send close event. Note, this includes both aborts and disconnects */
if (Events & FD_CLOSE) PollInfo.Events |= AFD_EVENT_DISCONNECT |
+ AFD_EVENT_CLOSE |
AFD_EVENT_ABORT;
/* Send PnP events related to live network hardware changes */
@@ -99,10 +100,12 @@
if (Status == STATUS_PENDING)
{
/* Wait for completion */
+ LeaveCriticalSection(&Socket->Lock);
SockWaitForSingleObject(ThreadData->EventHandle,
Socket->Handle,
NO_BLOCKING_HOOK,
NO_TIMEOUT);
+ EnterCriticalSection(&Socket->Lock);
/* Get new status */
Status = IoStatusBlock.Status;
@@ -273,10 +276,12 @@
if (Status == STATUS_PENDING)
{
/* Wait for completion */
+ LeaveCriticalSection(&Socket->Lock);
SockWaitForSingleObject(ThreadData->EventHandle,
Socket->Handle,
NO_BLOCKING_HOOK,
NO_TIMEOUT);
+ EnterCriticalSection(&Socket->Lock);
/* Get new status */
Status = IoStatusBlock.Status;
@@ -411,7 +416,11 @@
error:
/* Dereference the socket, if we have one here */
- if (Socket) SockDereferenceSocket(Socket);
+ if (Socket)
+ {
+ LeaveCriticalSection(&Socket->Lock);
+ SockDereferenceSocket(Socket);
+ }
/* Check for error */
if (ErrorCode != NO_ERROR)
Modified: branches/aicom-network-branch/dll/win32/mswsock/msafd/send.c
URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/dll/win32/…
==============================================================================
--- branches/aicom-network-branch/dll/win32/mswsock/msafd/send.c [iso-8859-1] (original)
+++ branches/aicom-network-branch/dll/win32/mswsock/msafd/send.c [iso-8859-1] Thu Aug 12
22:39:24 2010
@@ -246,7 +246,7 @@
INT SockaddrLength;
PSOCKADDR Sockaddr;
SOCKADDR_INFO SocketInfo;
-
+
/* Enter prolog */
ErrorCode = SockEnterApiFast(&ThreadData);
if (ErrorCode != NO_ERROR)
@@ -377,6 +377,8 @@
/* Make sure it's still unbound */
if (Socket->SharedData.State == SocketOpen)
{
+ LeaveCriticalSection(&Socket->Lock);
+
/* Bind it */
ReturnValue = WSPBind(Handle,
Sockaddr,
@@ -387,12 +389,13 @@
{
/* It's bound now, fake success */
ReturnValue = NO_ERROR;
+
+ LeaveCriticalSection(&Socket->Lock);
}
- /* Release the lock and free memory */
- LeaveCriticalSection(&Socket->Lock);
+ /* Free memory */
RtlFreeHeap(SockPrivateHeap, 0, Sockaddr);
-
+
/* Check if we failed */
if (ReturnValue == SOCKET_ERROR) goto error;
}