[AFD]
authorCameron Gutman <aicommander@gmail.com>
Mon, 30 May 2011 17:27:53 +0000 (17:27 +0000)
committerCameron Gutman <aicommander@gmail.com>
Mon, 30 May 2011 17:27:53 +0000 (17:27 +0000)
- Launch a new listen IRP right after the current one completes instead of waiting until the current pending connection is accepted
- Reduces the chance of AFD missing two connection requests that are issued very close together and increases network performance by allowing our connection queue to do its job

svn path=/trunk/; revision=52013

reactos/drivers/network/afd/afd/listen.c
reactos/drivers/network/afd/afd/tdiconn.c
reactos/drivers/network/afd/include/afd.h
reactos/drivers/network/afd/include/tdiconn.h

index f6eb110..c57bb0a 100644 (file)
@@ -178,18 +178,31 @@ static NTSTATUS NTAPI ListenComplete
                                 ListEntry ) );
     }
 
-    if( FCB->ListenIrp.ConnectionCallInfo ) {
-        ExFreePool( FCB->ListenIrp.ConnectionCallInfo );
-        FCB->ListenIrp.ConnectionCallInfo = NULL;
-    }
-
-    if( FCB->ListenIrp.ConnectionReturnInfo ) {
-        ExFreePool( FCB->ListenIrp.ConnectionReturnInfo );
-        FCB->ListenIrp.ConnectionReturnInfo = NULL;
+    /* Launch new accept socket */
+    Status = WarmSocketForConnection( FCB );
+        
+    if (NT_SUCCESS(Status))
+    {
+        Status = TdiBuildNullConnectionInfoInPlace(FCB->ListenIrp.ConnectionCallInfo,
+                                                   FCB->LocalAddress->Address[0].AddressType);
+        ASSERT(Status == STATUS_SUCCESS);
+        
+        Status = TdiBuildNullConnectionInfoInPlace(FCB->ListenIrp.ConnectionReturnInfo,
+                                                   FCB->LocalAddress->Address[0].AddressType);
+        ASSERT(Status == STATUS_SUCCESS);
+        
+        Status = TdiListen( &FCB->ListenIrp.InFlightRequest,
+                            FCB->Connection.Object,
+                            &FCB->ListenIrp.ConnectionCallInfo,
+                            &FCB->ListenIrp.ConnectionReturnInfo,
+                            &FCB->ListenIrp.Iosb,
+                            ListenComplete,
+                            FCB );
+
+        if (Status == STATUS_PENDING)
+            Status = STATUS_SUCCESS;
     }
 
-    FCB->NeedsNewListen = TRUE;
-
     /* Trigger a select return if appropriate */
     if( !IsListEmpty( &FCB->PendingConnections ) ) {
        FCB->PollState |= AFD_EVENT_ACCEPT;
@@ -264,9 +277,6 @@ NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
     if( Status == STATUS_PENDING )
        Status = STATUS_SUCCESS;
 
-    if (NT_SUCCESS(Status))
-        FCB->NeedsNewListen = FALSE;
-
     AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
     return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
 }
@@ -323,48 +333,6 @@ NTSTATUS AfdAccept( PDEVICE_OBJECT DeviceObject, PIRP Irp,
 
     if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
 
-    if( FCB->NeedsNewListen ) {
-       AFD_DbgPrint(MID_TRACE,("ADDRESSFILE: %x\n", FCB->AddressFile.Handle));
-
-       /* Launch new accept socket */
-       Status = WarmSocketForConnection( FCB );
-
-       if( Status == STATUS_SUCCESS ) {
-            Status = TdiBuildNullConnectionInfo
-               ( &FCB->ListenIrp.ConnectionCallInfo,
-                 FCB->LocalAddress->Address[0].AddressType );
-
-           if (!NT_SUCCESS(Status)) return UnlockAndMaybeComplete(FCB, Status, Irp, 0);
-
-           Status = TdiBuildNullConnectionInfo
-               ( &FCB->ListenIrp.ConnectionReturnInfo,
-                 FCB->LocalAddress->Address[0].AddressType );
-
-           if (!NT_SUCCESS(Status))
-           {
-               ExFreePool(FCB->ListenIrp.ConnectionCallInfo);
-               FCB->ListenIrp.ConnectionCallInfo = NULL;
-               return UnlockAndMaybeComplete(FCB, Status, Irp, 0);
-           }
-
-           Status = TdiListen( &FCB->ListenIrp.InFlightRequest,
-                               FCB->Connection.Object,
-                               &FCB->ListenIrp.ConnectionCallInfo,
-                               &FCB->ListenIrp.ConnectionReturnInfo,
-                               &FCB->ListenIrp.Iosb,
-                               ListenComplete,
-                               FCB );
-
-            if( Status == STATUS_PENDING )
-                Status = STATUS_SUCCESS;
-
-            if( !NT_SUCCESS(Status) )
-                return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
-
-           FCB->NeedsNewListen = FALSE;
-       } else return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
-    }
-
     for( PendingConn = FCB->PendingConnections.Flink;
         PendingConn != &FCB->PendingConnections;
         PendingConn = PendingConn->Flink ) {
index c95ed3b..b6a5e52 100644 (file)
@@ -77,7 +77,7 @@ PTRANSPORT_ADDRESS TaCopyTransportAddress( PTRANSPORT_ADDRESS OtherAddress ) {
        return A;
 }
 
-static NTSTATUS TdiBuildNullConnectionInfoInPlace
+NTSTATUS TdiBuildNullConnectionInfoInPlace
 ( PTDI_CONNECTION_INFORMATION ConnInfo,
   ULONG Type )
 /*
index ac3a286..2a6412a 100644 (file)
@@ -179,7 +179,7 @@ typedef struct _AFD_FCB {
     PVOID CurrentThread;
     PFILE_OBJECT FileObject;
     PAFD_DEVICE_EXTENSION DeviceExt;
-    BOOLEAN DelayedAccept, NeedsNewListen;
+    BOOLEAN DelayedAccept;
     UINT ConnSeq;
     PTRANSPORT_ADDRESS LocalAddress, RemoteAddress;
     PTDI_CONNECTION_INFORMATION AddressFrom, ConnectInfo;
index 54f83fc..662fc71 100644 (file)
@@ -19,7 +19,7 @@ NTSTATUS TdiBuildConnectionInfoInPlace
 ( PTDI_CONNECTION_INFORMATION ConnInfo, PTRANSPORT_ADDRESS Name );
 NTSTATUS TdiBuildConnectionInfo
 ( PTDI_CONNECTION_INFORMATION *ConnectionInfo, PTRANSPORT_ADDRESS Name );
-NTSTATUS TdiBuildNullConnectionInfoToPlace
+NTSTATUS TdiBuildNullConnectionInfoInPlace
 ( PTDI_CONNECTION_INFORMATION ConnInfo, ULONG Type );
 NTSTATUS TdiBuildNullConnectionInfo
 ( PTDI_CONNECTION_INFORMATION *ConnectionInfo, ULONG Type );