mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
- Implement IRP cancellation for AFD
- Fixes "Broken driver did not complete!" showing up in the debug log (especially during winetests) svn path=/trunk/; revision=43274
This commit is contained in:
parent
b809cead05
commit
5920b78ec2
7 changed files with 91 additions and 3 deletions
|
@ -99,6 +99,7 @@ static NTSTATUS NTAPI StreamSocketConnectComplete
|
|||
NextIrp->IoStatus.Status = STATUS_FILE_CLOSED;
|
||||
NextIrp->IoStatus.Information = 0;
|
||||
if( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
|
||||
(void)IoSetCancelRoutine(NextIrp, NULL);
|
||||
IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
|
||||
}
|
||||
SocketStateUnlock( FCB );
|
||||
|
@ -120,6 +121,7 @@ static NTSTATUS NTAPI StreamSocketConnectComplete
|
|||
NextIrp->IoStatus.Status = Status;
|
||||
NextIrp->IoStatus.Information = 0;
|
||||
if( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
|
||||
(void)IoSetCancelRoutine(NextIrp, NULL);
|
||||
IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ static NTSTATUS SatisfyPreAccept( PIRP Irp, PAFD_TDI_OBJECT_QELT Qelt ) {
|
|||
if( Irp->MdlAddress ) UnlockRequest( Irp, IoGetCurrentIrpStackLocation( Irp ) );
|
||||
Irp->IoStatus.Status = STATUS_NO_MEMORY;
|
||||
Irp->IoStatus.Information = 0;
|
||||
(void)IoSetCancelRoutine(Irp, NULL);
|
||||
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
@ -79,6 +80,7 @@ static NTSTATUS SatisfyPreAccept( PIRP Irp, PAFD_TDI_OBJECT_QELT Qelt ) {
|
|||
|
||||
Irp->IoStatus.Information = ((PCHAR)&IPAddr[1]) - ((PCHAR)ListenReceive);
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
(void)IoSetCancelRoutine(Irp, NULL);
|
||||
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -106,6 +108,7 @@ static NTSTATUS NTAPI ListenComplete
|
|||
NextIrp->IoStatus.Status = STATUS_FILE_CLOSED;
|
||||
NextIrp->IoStatus.Information = 0;
|
||||
if( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
|
||||
(void)IoSetCancelRoutine(NextIrp, NULL);
|
||||
IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
|
||||
}
|
||||
|
||||
|
|
|
@ -302,6 +302,7 @@ NTSTATUS NTAPI UnlockAndMaybeComplete
|
|||
SocketStateUnlock( FCB );
|
||||
} else {
|
||||
if ( Irp->MdlAddress ) UnlockRequest( Irp, IoGetCurrentIrpStackLocation( Irp ) );
|
||||
(void)IoSetCancelRoutine(Irp, NULL);
|
||||
SocketStateUnlock( FCB );
|
||||
IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
|
||||
}
|
||||
|
@ -323,6 +324,6 @@ NTSTATUS LeaveIrpUntilLater( PAFD_FCB FCB, PIRP Irp, UINT Function ) {
|
|||
InsertTailList( &FCB->PendingIrpList[Function],
|
||||
&Irp->Tail.Overlay.ListEntry );
|
||||
IoMarkIrpPending(Irp);
|
||||
Irp->IoStatus.Status = STATUS_PENDING;
|
||||
(void)IoSetCancelRoutine(Irp, AfdCancelHandler);
|
||||
return UnlockAndMaybeComplete( FCB, STATUS_PENDING, Irp, 0 );
|
||||
}
|
||||
|
|
|
@ -505,6 +505,78 @@ AfdDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
return (Status);
|
||||
}
|
||||
|
||||
VOID NTAPI
|
||||
AfdCancelHandler(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||
PAFD_FCB FCB = FileObject->FsContext;
|
||||
UINT Function;
|
||||
PAFD_RECV_INFO RecvReq;
|
||||
PAFD_SEND_INFO SendReq;
|
||||
PLIST_ENTRY CurrentEntry;
|
||||
PIRP CurrentIrp;
|
||||
|
||||
IoReleaseCancelSpinLock(Irp->CancelIrql);
|
||||
|
||||
if (!SocketAcquireStateLock(FCB))
|
||||
return;
|
||||
|
||||
ASSERT(IrpSp->MajorFunction == IRP_MJ_DEVICE_CONTROL);
|
||||
|
||||
switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
|
||||
{
|
||||
case IOCTL_AFD_RECV:
|
||||
RecvReq = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
|
||||
UnlockBuffers(RecvReq->BufferArray, RecvReq->BufferCount, FALSE);
|
||||
/* Fall through */
|
||||
|
||||
case IOCTL_AFD_RECV_DATAGRAM:
|
||||
Function = FUNCTION_RECV;
|
||||
break;
|
||||
|
||||
case IOCTL_AFD_SEND:
|
||||
SendReq = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
|
||||
UnlockBuffers(SendReq->BufferArray, SendReq->BufferCount, FALSE);
|
||||
/* Fall through */
|
||||
|
||||
case IOCTL_AFD_SEND_DATAGRAM:
|
||||
Function = FUNCTION_SEND;
|
||||
break;
|
||||
|
||||
case IOCTL_AFD_CONNECT:
|
||||
Function = FUNCTION_CONNECT;
|
||||
break;
|
||||
|
||||
case IOCTL_AFD_WAIT_FOR_LISTEN:
|
||||
Function = FUNCTION_PREACCEPT;
|
||||
break;
|
||||
|
||||
default:
|
||||
ASSERT(FALSE);
|
||||
break;
|
||||
}
|
||||
|
||||
CurrentEntry = FCB->PendingIrpList[Function].Flink;
|
||||
while (CurrentEntry != &FCB->PendingIrpList[Function])
|
||||
{
|
||||
CurrentIrp = CONTAINING_RECORD(CurrentEntry, IRP, Tail.Overlay.ListEntry);
|
||||
|
||||
if (CurrentIrp == Irp)
|
||||
{
|
||||
RemoveEntryList(CurrentEntry);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentEntry = CurrentEntry->Flink;
|
||||
}
|
||||
}
|
||||
|
||||
UnlockAndMaybeComplete(FCB, STATUS_CANCELLED, Irp, 0);
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
AfdUnload(PDRIVER_OBJECT DriverObject)
|
||||
{
|
||||
|
|
|
@ -154,6 +154,7 @@ static NTSTATUS ReceiveActivity( PAFD_FCB FCB, PIRP Irp ) {
|
|||
RetBytesCopied = TotalBytesCopied;
|
||||
}
|
||||
if( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
|
||||
(void)IoSetCancelRoutine(NextIrp, NULL);
|
||||
IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
|
||||
}
|
||||
}
|
||||
|
@ -210,6 +211,7 @@ NTSTATUS NTAPI ReceiveComplete
|
|||
NextIrp->IoStatus.Information = 0;
|
||||
UnlockBuffers(RecvReq->BufferArray, RecvReq->BufferCount, FALSE);
|
||||
if( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
|
||||
(void)IoSetCancelRoutine(NextIrp, NULL);
|
||||
IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
|
||||
}
|
||||
SocketStateUnlock( FCB );
|
||||
|
@ -292,6 +294,7 @@ AfdConnectedSocketReadData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
} else if( Status == STATUS_PENDING ) {
|
||||
AFD_DbgPrint(MID_TRACE,("Leaving read irp\n"));
|
||||
IoMarkIrpPending( Irp );
|
||||
(void)IoSetCancelRoutine(Irp, AfdCancelHandler);
|
||||
} else {
|
||||
AFD_DbgPrint(MID_TRACE,("Completed with status %x\n", Status));
|
||||
}
|
||||
|
@ -427,6 +430,7 @@ PacketSocketRecvComplete(
|
|||
NextIrp->IoStatus.Information = 0;
|
||||
UnlockBuffers(RecvReq->BufferArray, RecvReq->BufferCount, FALSE);
|
||||
if( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
|
||||
(void)IoSetCancelRoutine(NextIrp, NULL);
|
||||
IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
|
||||
}
|
||||
|
||||
|
@ -489,6 +493,7 @@ PacketSocketRecvComplete(
|
|||
NextIrp->IoStatus.Information = DatagramRecv->Len;
|
||||
UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, TRUE );
|
||||
if ( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
|
||||
(void)IoSetCancelRoutine(NextIrp, NULL);
|
||||
IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
|
||||
} else {
|
||||
AFD_DbgPrint(MID_TRACE,("Satisfying\n"));
|
||||
|
@ -499,6 +504,7 @@ PacketSocketRecvComplete(
|
|||
UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, TRUE );
|
||||
if ( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
|
||||
AFD_DbgPrint(MID_TRACE,("Completing\n"));
|
||||
(void)IoSetCancelRoutine(NextIrp, NULL);
|
||||
IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ static NTSTATUS NTAPI SendComplete
|
|||
NextIrp->IoStatus.Information = 0;
|
||||
UnlockBuffers(SendReq->BufferArray, SendReq->BufferCount, FALSE);
|
||||
if( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
|
||||
(void)IoSetCancelRoutine(NextIrp, NULL);
|
||||
IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
|
||||
}
|
||||
SocketStateUnlock( FCB );
|
||||
|
@ -82,7 +83,7 @@ static NTSTATUS NTAPI SendComplete
|
|||
NextIrp->IoStatus.Information = 0;
|
||||
|
||||
if ( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
|
||||
|
||||
(void)IoSetCancelRoutine(NextIrp, NULL);
|
||||
IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
|
||||
}
|
||||
|
||||
|
@ -197,6 +198,7 @@ static NTSTATUS NTAPI PacketSocketSendComplete
|
|||
NextIrp->IoStatus.Status = STATUS_FILE_CLOSED;
|
||||
NextIrp->IoStatus.Information = 0;
|
||||
if( NextIrp->MdlAddress ) UnlockRequest( NextIrp, IoGetCurrentIrpStackLocation( NextIrp ) );
|
||||
(void)IoSetCancelRoutine(NextIrp, NULL);
|
||||
IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
|
||||
}
|
||||
SocketStateUnlock( FCB );
|
||||
|
|
|
@ -279,6 +279,8 @@ VOID UnlockRequest( PIRP Irp, PIO_STACK_LOCATION IrpSp );
|
|||
VOID OskitDumpBuffer( PCHAR Buffer, UINT Len );
|
||||
NTSTATUS LeaveIrpUntilLater( PAFD_FCB FCB, PIRP Irp, UINT Function );
|
||||
VOID DestroySocket( PAFD_FCB FCB );
|
||||
VOID NTAPI AfdCancelHandler(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp);
|
||||
|
||||
/* read.c */
|
||||
|
||||
|
|
Loading…
Reference in a new issue