mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
Allow cancelling of listen IRPs
svn path=/trunk/; revision=14037
This commit is contained in:
parent
6f699ce531
commit
c367070483
3 changed files with 62 additions and 5 deletions
|
@ -109,16 +109,16 @@ VOID TCPAbortListenForSocket( PCONNECTION_ENDPOINT Listener,
|
|||
|
||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||
|
||||
for( ListEntry = Listener->ListenRequest.Flink;
|
||||
ListEntry != &Listener->ListenRequest;
|
||||
ListEntry = ListEntry->Flink ) {
|
||||
ListEntry = Listener->ListenRequest.Flink;
|
||||
while ( ListEntry != &Listener->ListenRequest ) {
|
||||
Bucket = CONTAINING_RECORD(ListEntry, TDI_BUCKET, Entry);
|
||||
ListEntry = ListEntry->Flink;
|
||||
|
||||
if( Bucket->Request.Handle.ConnectionContext == Connection ) {
|
||||
if( Bucket->AssociatedEndpoint == Connection ) {
|
||||
#ifdef MEMTRACK
|
||||
UntrackFL( __FILE__, __LINE__, Bucket->Request.RequestContext );
|
||||
#endif
|
||||
RemoveEntryList( ListEntry );
|
||||
RemoveEntryList( ListEntry->Blink );
|
||||
ExFreePool( Bucket );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,11 @@ NTSTATUS DDKAPI ListenComplete
|
|||
PAFD_FCB FCB = (PAFD_FCB)Context;
|
||||
PAFD_TDI_OBJECT_QELT Qelt;
|
||||
|
||||
if ( Irp->Cancel ) {
|
||||
/* FIXME: is this anything else we need to do? */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if( !SocketAcquireStateLock( FCB ) ) return Status;
|
||||
|
||||
FCB->ListenIrp.InFlightRequest = NULL;
|
||||
|
|
|
@ -219,6 +219,52 @@ VOID DDKAPI DispCancelRequest(
|
|||
}
|
||||
|
||||
|
||||
VOID DDKAPI DispCancelListenRequest(
|
||||
PDEVICE_OBJECT Device,
|
||||
PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: Cancels a listen IRP
|
||||
* ARGUMENTS:
|
||||
* Device = Pointer to device object
|
||||
* Irp = Pointer to an I/O request packet
|
||||
*/
|
||||
{
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
PTRANSPORT_CONTEXT TranContext;
|
||||
PFILE_OBJECT FileObject;
|
||||
PCONNECTION_ENDPOINT Connection;
|
||||
/*NTSTATUS Status = STATUS_SUCCESS;*/
|
||||
|
||||
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
|
||||
|
||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
FileObject = IrpSp->FileObject;
|
||||
TranContext = (PTRANSPORT_CONTEXT)FileObject->FsContext;
|
||||
ASSERT( TDI_LISTEN == IrpSp->MinorFunction);
|
||||
|
||||
TI_DbgPrint(DEBUG_IRP, ("IRP at (0x%X).\n", Irp));
|
||||
|
||||
#ifdef DBG
|
||||
if (!Irp->Cancel)
|
||||
TI_DbgPrint(MIN_TRACE, ("Irp->Cancel is FALSE, should be TRUE.\n"));
|
||||
#endif
|
||||
|
||||
/* Try canceling the request */
|
||||
Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext;
|
||||
TCPAbortListenForSocket(
|
||||
Connection->AddressFile->Listener,
|
||||
Connection );
|
||||
|
||||
IoReleaseCancelSpinLock(Irp->CancelIrql);
|
||||
|
||||
DispDataRequestComplete(Irp, STATUS_CANCELLED, 0);
|
||||
|
||||
DispCancelComplete(FileObject);
|
||||
|
||||
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS DispTdiAccept(
|
||||
PIRP Irp)
|
||||
/*
|
||||
|
@ -536,6 +582,12 @@ NTSTATUS DispTdiListen(
|
|||
Status = TCPListen( Connection->AddressFile->Listener, 1024 );
|
||||
/* BACKLOG */
|
||||
}
|
||||
if( NT_SUCCESS(Status) ) {
|
||||
Status = DispPrepareIrpForCancel
|
||||
(TranContext->Handle.ConnectionContext,
|
||||
Irp,
|
||||
(PDRIVER_CANCEL)DispCancelListenRequest);
|
||||
}
|
||||
|
||||
if( NT_SUCCESS(Status) ) {
|
||||
Status = TCPAccept
|
||||
|
|
Loading…
Reference in a new issue