Author: cgutman
Date: Sat Jun 19 05:04:40 2010
New Revision: 47803
URL:
http://svn.reactos.org/svn/reactos?rev=47803&view=rev
Log:
[MSAFD]
- Add locking to protect the socket list
Modified:
trunk/reactos/dll/win32/msafd/misc/dllmain.c
Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/dllma…
==============================================================================
--- trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Sat Jun 19 05:04:40 2010
@@ -23,6 +23,7 @@
WSPUPCALLTABLE Upcalls;
LPWPUCOMPLETEOVERLAPPEDREQUEST lpWPUCompleteOverlappedRequest;
PSOCKET_INFORMATION SocketListHead = NULL;
+CRITICAL_SECTION SocketListLock;
LIST_ENTRY SockHelpersListHead = { NULL, NULL };
ULONG SockAsyncThreadRefCount;
HANDLE SockAsyncHelperAfdHandle;
@@ -280,8 +281,10 @@
NULL);
/* Save in Process Sockets List */
+ EnterCriticalSection(&SocketListLock);
Socket->NextSocket = SocketListHead;
SocketListHead = Socket;
+ LeaveCriticalSection(&SocketListLock);
/* Create the Socket Context */
CreateContext(Socket);
@@ -556,6 +559,7 @@
NtClose(Socket->TdiConnectionHandle);
Socket->TdiConnectionHandle = NULL;
+ EnterCriticalSection(&SocketListLock);
if (SocketListHead == Socket)
{
SocketListHead = SocketListHead->NextSocket;
@@ -574,6 +578,7 @@
CurrentSocket = CurrentSocket->NextSocket;
}
}
+ LeaveCriticalSection(&SocketListLock);
HeapFree(GlobalHeap, 0, Socket);
@@ -2314,14 +2319,21 @@
{
PSOCKET_INFORMATION CurrentSocket;
+ EnterCriticalSection(&SocketListLock);
+
CurrentSocket = SocketListHead;
while (CurrentSocket)
{
if (CurrentSocket->Handle == Handle)
+ {
+ LeaveCriticalSection(&SocketListLock);
return CurrentSocket;
+ }
CurrentSocket = CurrentSocket->NextSocket;
}
+
+ LeaveCriticalSection(&SocketListLock);
return NULL;
}
@@ -2841,6 +2853,9 @@
/* Heap to use when allocating */
GlobalHeap = GetProcessHeap();
+ /* Initialize the lock that protects our socket list */
+ InitializeCriticalSection(&SocketListLock);
+
AFD_DbgPrint(MAX_TRACE, ("MSAFD.DLL has been loaded\n"));
break;
@@ -2852,6 +2867,10 @@
break;
case DLL_PROCESS_DETACH:
+
+ /* Delete the socket list lock */
+ DeleteCriticalSection(&SocketListLock);
+
break;
}