diff --git a/reactos/drivers/network/afd/afd/listen.c b/reactos/drivers/network/afd/afd/listen.c index f6eb1104210..c57bb0a9309 100644 --- a/reactos/drivers/network/afd/afd/listen.c +++ b/reactos/drivers/network/afd/afd/listen.c @@ -178,18 +178,31 @@ static NTSTATUS NTAPI ListenComplete ListEntry ) ); } - if( FCB->ListenIrp.ConnectionCallInfo ) { - ExFreePool( FCB->ListenIrp.ConnectionCallInfo ); - FCB->ListenIrp.ConnectionCallInfo = 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( FCB->ListenIrp.ConnectionReturnInfo ) { - ExFreePool( FCB->ListenIrp.ConnectionReturnInfo ); - FCB->ListenIrp.ConnectionReturnInfo = NULL; + 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 ) { diff --git a/reactos/drivers/network/afd/afd/tdiconn.c b/reactos/drivers/network/afd/afd/tdiconn.c index c95ed3bd423..b6a5e523fc2 100644 --- a/reactos/drivers/network/afd/afd/tdiconn.c +++ b/reactos/drivers/network/afd/afd/tdiconn.c @@ -77,7 +77,7 @@ PTRANSPORT_ADDRESS TaCopyTransportAddress( PTRANSPORT_ADDRESS OtherAddress ) { return A; } -static NTSTATUS TdiBuildNullConnectionInfoInPlace +NTSTATUS TdiBuildNullConnectionInfoInPlace ( PTDI_CONNECTION_INFORMATION ConnInfo, ULONG Type ) /* diff --git a/reactos/drivers/network/afd/include/afd.h b/reactos/drivers/network/afd/include/afd.h index ac3a286cd6c..2a6412a6d1e 100644 --- a/reactos/drivers/network/afd/include/afd.h +++ b/reactos/drivers/network/afd/include/afd.h @@ -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; diff --git a/reactos/drivers/network/afd/include/tdiconn.h b/reactos/drivers/network/afd/include/tdiconn.h index 54f83fc722a..662fc71f834 100644 --- a/reactos/drivers/network/afd/include/tdiconn.h +++ b/reactos/drivers/network/afd/include/tdiconn.h @@ -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 );