[ros-diffs] [janderwald] 51047: [MSAFD] - Print the caller in MsafdReturnWithErrno - Initialize SockAsyncCompletionPort handle - Check if the creation of the completion port failed - Defer free of the socket i...

janderwald at svn.reactos.org janderwald at svn.reactos.org
Mon Mar 14 12:48:30 UTC 2011


Author: janderwald
Date: Mon Mar 14 12:48:28 2011
New Revision: 51047

URL: http://svn.reactos.org/svn/reactos?rev=51047&view=rev
Log:
[MSAFD]
- Print the caller in MsafdReturnWithErrno
- Initialize SockAsyncCompletionPort handle
- Check if the creation of the completion port failed
- Defer free of the socket information struct until the socket handle has been closed because the socket may have a pending select. When the socket is closed, the pending select is canceled, thus a apc routine is invoked which access the freed socket information struct.
- Fixes mIRC crash
- Should be merged to 0.3.13 branch

Modified:
    trunk/reactos/dll/win32/msafd/misc/dllmain.c
    trunk/reactos/dll/win32/msafd/msafd.h

Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/dllmain.c?rev=51047&r1=51046&r2=51047&view=diff
==============================================================================
--- trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Mon Mar 14 12:48:28 2011
@@ -27,7 +27,7 @@
 LIST_ENTRY SockHelpersListHead = { NULL, NULL };
 ULONG SockAsyncThreadRefCount;
 HANDLE SockAsyncHelperAfdHandle;
-HANDLE SockAsyncCompletionPort;
+HANDLE SockAsyncCompletionPort = NULL;
 BOOLEAN SockAsyncSelectCalled;
 
 
@@ -562,12 +562,11 @@
     }
     LeaveCriticalSection(&SocketListLock);
 
-    HeapFree(GlobalHeap, 0, Socket);
-
     /* Close the handle */
     NtClose((HANDLE)Handle);
     NtClose(SockEvent);
 
+    HeapFree(GlobalHeap, 0, Socket);
     return MsafdReturnWithErrno(Status, lpErrno, 0, NULL);
 }
 
@@ -2420,6 +2419,7 @@
     /* Check if the Thread Already Exists */
     if (SockAsyncThreadRefCount)
     {
+        ASSERT(SockAsyncCompletionPort);
         return TRUE;
     }
 
@@ -2430,7 +2430,11 @@
                                       IO_COMPLETION_ALL_ACCESS,
                                       NULL,
                                       2); // Allow 2 threads only
-
+        if (!NT_SUCCESS(Status))
+        {
+             AFD_DbgPrint(MID_TRACE,("Failed to create completion port\n"));
+             return FALSE;
+        }
         /* Protect Handle */	
         HandleFlags.ProtectFromClose = TRUE;
         HandleFlags.Inherit = FALSE;

Modified: trunk/reactos/dll/win32/msafd/msafd.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/msafd.h?rev=51047&r1=51046&r2=51047&view=diff
==============================================================================
--- trunk/reactos/dll/win32/msafd/msafd.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/msafd.h [iso-8859-1] Mon Mar 14 12:48:28 2011
@@ -488,7 +488,7 @@
     }
     else
     {
-        DbgPrint("%s: Received invalid lpErrno pointer!\n", __FUNCTION__);
+        DbgPrint("%s: Received invalid lpErrno pointer! %s\n", __FUNCTION__);
 
         if (ReturnedBytes)
             *ReturnedBytes = (Status == STATUS_SUCCESS) ? Received : 0;




More information about the Ros-diffs mailing list