Author: cmihail
Date: Fri May 27 19:37:28 2011
New Revision: 51962

URL: http://svn.reactos.org/svn/reactos?rev=51962&view=rev
Log:
[TCPIP]
Closing a socket while in listening state (that has not accepted any 
connections) no longer certainly crashes the system. There's still a tendency 
to crash the system sometimes, but it's related to possibly not canceling any 
outstanding IRPs for the listening socket.

Modified:
    branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/accept.c

Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/accept.c
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/accept.c?rev=51962&r1=51961&r2=51962&view=diff
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/accept.c 
[iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/accept.c 
[iso-8859-1] Fri May 27 19:37:28 2011
@@ -83,7 +83,8 @@
 }
 
 BOOLEAN TCPAbortListenForSocket( PCONNECTION_ENDPOINT Listener,
-                  PCONNECTION_ENDPOINT Connection ) {
+                  PCONNECTION_ENDPOINT Connection )
+{
     PLIST_ENTRY ListEntry;
     PTDI_BUCKET Bucket;
     KIRQL OldIrql;
@@ -92,18 +93,20 @@
     LockObject(Listener, &OldIrql);
 
     ListEntry = Listener->ListenRequest.Flink;
-    while ( ListEntry != &Listener->ListenRequest ) {
-    Bucket = CONTAINING_RECORD(ListEntry, TDI_BUCKET, Entry);
+    while ( ListEntry != &Listener->ListenRequest )
+    {
+        Bucket = CONTAINING_RECORD(ListEntry, TDI_BUCKET, Entry);
 
-    if( Bucket->AssociatedEndpoint == Connection ) {
-        DereferenceObject(Bucket->AssociatedEndpoint);
-        RemoveEntryList( &Bucket->Entry );
-        ExFreePoolWithTag( Bucket, TDI_BUCKET_TAG );
-        Found = TRUE;
-        break;
-    }
+        if( Bucket->AssociatedEndpoint == Connection )
+        {
+            DereferenceObject(Bucket->AssociatedEndpoint);
+            RemoveEntryList( &Bucket->Entry );
+            ExFreePoolWithTag( Bucket, TDI_BUCKET_TAG );
+            Found = TRUE;
+            break;
+        }
 
-    ListEntry = ListEntry->Flink;
+        ListEntry = ListEntry->Flink;
     }
 
     UnlockObject(Listener, OldIrql);
@@ -131,6 +134,8 @@
     if( Bucket )
     {
         Bucket->AssociatedEndpoint = Connection;
+        ReferenceObject(Bucket->AssociatedEndpoint);
+
         Bucket->Request.RequestNotifyObject = Complete;
         Bucket->Request.RequestContext = Context;
         InsertTailList( &Listener->ListenRequest, &Bucket->Entry );


Reply via email to