mirror of
https://github.com/reactos/reactos.git
synced 2024-08-14 15:16:27 +00:00
Merge aicom-network-fixes up to 35486
svn path=/trunk/; revision=35499
This commit is contained in:
parent
4d54d71f8f
commit
36b8b4a111
|
@ -135,22 +135,21 @@ AfdGetSockOrPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
|
||||
if( NT_SUCCESS(Status) ) {
|
||||
Status = TdiQueryInformation
|
||||
( FCB->AddressFile.Object,
|
||||
( FCB->Connection.Object,
|
||||
TDI_QUERY_CONNECTION_INFO,
|
||||
SysMdl );
|
||||
}
|
||||
|
||||
if( NT_SUCCESS(Status) ) {
|
||||
TransAddr =
|
||||
(PTRANSPORT_ADDRESS)MmMapLockedPages
|
||||
( Mdl, IoModifyAccess );
|
||||
}
|
||||
(PTRANSPORT_ADDRESS)MmGetSystemAddressForMdlSafe( Mdl, NormalPagePriority );
|
||||
|
||||
if( TransAddr )
|
||||
RtlCopyMemory( TransAddr, ConnInfo->RemoteAddress,
|
||||
TaLengthOfTransportAddress
|
||||
( ConnInfo->RemoteAddress ) );
|
||||
else Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
if( TransAddr )
|
||||
RtlCopyMemory( TransAddr, ConnInfo->RemoteAddress,
|
||||
TaLengthOfTransportAddress
|
||||
( ConnInfo->RemoteAddress ) );
|
||||
else Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
if( ConnInfo ) ExFreePool( ConnInfo );
|
||||
if( SysMdl ) IoFreeMdl( SysMdl );
|
||||
|
|
|
@ -87,15 +87,15 @@ static NTSTATUS NTAPI ListenComplete
|
|||
PAFD_FCB FCB = (PAFD_FCB)Context;
|
||||
PAFD_TDI_OBJECT_QELT Qelt;
|
||||
|
||||
if( Irp->Cancel ) {
|
||||
if( FCB ) FCB->ListenIrp.InFlightRequest = NULL;
|
||||
return STATUS_CANCELLED;
|
||||
}
|
||||
|
||||
if( !SocketAcquireStateLock( FCB ) ) return Status;
|
||||
|
||||
FCB->ListenIrp.InFlightRequest = NULL;
|
||||
|
||||
if( Irp->Cancel ) {
|
||||
SocketStateUnlock( FCB );
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if( FCB->State == SOCKET_STATE_CLOSED ) {
|
||||
SocketStateUnlock( FCB );
|
||||
DestroySocket( FCB );
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
/* Lock a method_neither request so it'll be available from DISPATCH_LEVEL */
|
||||
PVOID LockRequest( PIRP Irp, PIO_STACK_LOCATION IrpSp ) {
|
||||
BOOLEAN LockFailed = FALSE;
|
||||
|
||||
Irp->MdlAddress =
|
||||
IoAllocateMdl( IrpSp->Parameters.DeviceIoControl.Type3InputBuffer,
|
||||
IrpSp->Parameters.DeviceIoControl.InputBufferLength,
|
||||
|
@ -22,14 +24,34 @@ PVOID LockRequest( PIRP Irp, PIO_STACK_LOCATION IrpSp ) {
|
|||
FALSE,
|
||||
NULL );
|
||||
if( Irp->MdlAddress ) {
|
||||
MmProbeAndLockPages( Irp->MdlAddress, KernelMode, IoModifyAccess );
|
||||
_SEH_TRY {
|
||||
MmProbeAndLockPages( Irp->MdlAddress, KernelMode, IoModifyAccess );
|
||||
} _SEH_HANDLE {
|
||||
LockFailed = TRUE;
|
||||
} _SEH_END;
|
||||
|
||||
if( LockFailed ) {
|
||||
IoFreeMdl( Irp->MdlAddress );
|
||||
Irp->MdlAddress = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IrpSp->Parameters.DeviceIoControl.Type3InputBuffer =
|
||||
MmMapLockedPages( Irp->MdlAddress, KernelMode );
|
||||
|
||||
if( !IrpSp->Parameters.DeviceIoControl.Type3InputBuffer ) {
|
||||
IoFreeMdl( Irp->MdlAddress );
|
||||
Irp->MdlAddress = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
VOID UnlockRequest( PIRP Irp, PIO_STACK_LOCATION IrpSp ) {
|
||||
if( !IrpSp->Parameters.DeviceIoControl.Type3InputBuffer || !Irp->MdlAddress ) return;
|
||||
|
||||
MmUnmapLockedPages( IrpSp->Parameters.DeviceIoControl.Type3InputBuffer,
|
||||
Irp->MdlAddress );
|
||||
MmUnlockPages( Irp->MdlAddress );
|
||||
|
|
|
@ -190,9 +190,7 @@ VOID DestroySocket( PAFD_FCB FCB ) {
|
|||
if( InFlightRequest[i]->InFlightRequest ) {
|
||||
AFD_DbgPrint(MID_TRACE,("Cancelling in flight irp %d (%x)\n",
|
||||
i, InFlightRequest[i]->InFlightRequest));
|
||||
InFlightRequest[i]->InFlightRequest->IoStatus.Status = STATUS_CANCELLED;
|
||||
InFlightRequest[i]->InFlightRequest->IoStatus.Information = 0;
|
||||
IoCancelIrp( InFlightRequest[i]->InFlightRequest );
|
||||
InFlightRequest[i]->InFlightRequest = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -233,6 +233,11 @@ NTSTATUS NTAPI ReceiveComplete
|
|||
|
||||
ASSERT_IRQL(APC_LEVEL);
|
||||
|
||||
if( Irp->Cancel ) {
|
||||
if( FCB ) FCB->ReceiveIrp.InFlightRequest = NULL;
|
||||
return STATUS_CANCELLED;
|
||||
}
|
||||
|
||||
if( !SocketAcquireStateLock( FCB ) ) return Status;
|
||||
|
||||
FCB->ReceiveIrp.InFlightRequest = NULL;
|
||||
|
@ -449,6 +454,11 @@ PacketSocketRecvComplete(
|
|||
|
||||
AFD_DbgPrint(MID_TRACE,("Called on %x\n", FCB));
|
||||
|
||||
if( Irp->Cancel ) {
|
||||
if( FCB ) FCB->ReceiveIrp.InFlightRequest = NULL;
|
||||
return STATUS_CANCELLED;
|
||||
}
|
||||
|
||||
if( !SocketAcquireStateLock( FCB ) ) return STATUS_FILE_CLOSED;
|
||||
|
||||
FCB->ReceiveIrp.InFlightRequest = NULL;
|
||||
|
|
|
@ -40,6 +40,11 @@ static NTSTATUS NTAPI SendComplete
|
|||
|
||||
ASSERT_IRQL(APC_LEVEL);
|
||||
|
||||
if( Irp->Cancel ) {
|
||||
if( FCB ) FCB->SendIrp.InFlightRequest = NULL;
|
||||
return STATUS_CANCELLED;
|
||||
}
|
||||
|
||||
if( !SocketAcquireStateLock( FCB ) ) return Status;
|
||||
|
||||
FCB->SendIrp.InFlightRequest = NULL;
|
||||
|
@ -170,6 +175,11 @@ static NTSTATUS NTAPI PacketSocketSendComplete
|
|||
Irp->IoStatus.Status,
|
||||
Irp->IoStatus.Information));
|
||||
|
||||
if( Irp->Cancel ) {
|
||||
if( FCB ) FCB->SendIrp.InFlightRequest = NULL;
|
||||
return STATUS_CANCELLED;
|
||||
}
|
||||
|
||||
/* It's ok if the FCB already died */
|
||||
if( !SocketAcquireStateLock( FCB ) ) return STATUS_SUCCESS;
|
||||
|
||||
|
@ -264,22 +274,6 @@ AfdConnectedSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
return UnlockAndMaybeComplete
|
||||
( FCB, STATUS_NO_MEMORY, Irp, TotalBytesCopied, NULL );
|
||||
|
||||
AFD_DbgPrint(MID_TRACE,("Socket state %d\n", FCB->State));
|
||||
|
||||
if( FCB->State != SOCKET_STATE_CONNECTED ) {
|
||||
if( SendReq->AfdFlags & AFD_IMMEDIATE ) {
|
||||
AFD_DbgPrint(MID_TRACE,("Nonblocking\n"));
|
||||
return UnlockAndMaybeComplete
|
||||
( FCB, STATUS_CANT_WAIT, Irp, 0, NULL );
|
||||
} else {
|
||||
AFD_DbgPrint(MID_TRACE,("Queuing request\n"));
|
||||
return LeaveIrpUntilLater( FCB, Irp, FUNCTION_SEND );
|
||||
}
|
||||
}
|
||||
|
||||
AFD_DbgPrint(MID_TRACE,("We already have %d bytes waiting.\n",
|
||||
FCB->Send.BytesUsed));
|
||||
|
||||
SendReq->BufferArray = LockBuffers( SendReq->BufferArray,
|
||||
SendReq->BufferCount,
|
||||
NULL, NULL,
|
||||
|
@ -290,6 +284,20 @@ AfdConnectedSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
Irp, 0, NULL );
|
||||
}
|
||||
|
||||
AFD_DbgPrint(MID_TRACE,("Socket state %d\n", FCB->State));
|
||||
|
||||
if( FCB->State != SOCKET_STATE_CONNECTED ) {
|
||||
if( SendReq->AfdFlags & AFD_IMMEDIATE ) {
|
||||
AFD_DbgPrint(MID_TRACE,("Nonblocking\n"));
|
||||
UnlockBuffers( SendReq->BufferArray, SendReq->BufferCount, FALSE );
|
||||
return UnlockAndMaybeComplete
|
||||
( FCB, STATUS_CANT_WAIT, Irp, 0, NULL );
|
||||
} else {
|
||||
AFD_DbgPrint(MID_TRACE,("Queuing request\n"));
|
||||
return LeaveIrpUntilLater( FCB, Irp, FUNCTION_SEND );
|
||||
}
|
||||
}
|
||||
|
||||
AFD_DbgPrint(MID_TRACE,("FCB->Send.BytesUsed = %d\n",
|
||||
FCB->Send.BytesUsed));
|
||||
|
||||
|
@ -362,6 +370,7 @@ AfdConnectedSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
|||
|
||||
if( SendReq->AfdFlags & AFD_IMMEDIATE ) {
|
||||
AFD_DbgPrint(MID_TRACE,("Nonblocking\n"));
|
||||
UnlockBuffers( SendReq->BufferArray, SendReq->BufferCount, FALSE );
|
||||
return UnlockAndMaybeComplete
|
||||
( FCB, STATUS_CANT_WAIT, Irp, 0, NULL );
|
||||
} else {
|
||||
|
|
|
@ -53,34 +53,6 @@ NTSTATUS DispPrepareIrpForCancel(
|
|||
return IRPFinish(Irp, STATUS_CANCELLED);
|
||||
}
|
||||
|
||||
|
||||
VOID DispCancelComplete(
|
||||
PVOID Context)
|
||||
/*
|
||||
* FUNCTION: Completes a cancel request
|
||||
* ARGUMENTS:
|
||||
* Context = Pointer to context information (FILE_OBJECT)
|
||||
*/
|
||||
{
|
||||
/*KIRQL OldIrql;*/
|
||||
PFILE_OBJECT FileObject;
|
||||
PTRANSPORT_CONTEXT TranContext;
|
||||
|
||||
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
|
||||
|
||||
FileObject = (PFILE_OBJECT)Context;
|
||||
TranContext = (PTRANSPORT_CONTEXT)FileObject->FsContext;
|
||||
|
||||
/* Set the cleanup event */
|
||||
KeSetEvent(&TranContext->CleanupEvent, 0, FALSE);
|
||||
|
||||
/* We are expected to release the cancel spin lock */
|
||||
/*IoReleaseCancelSpinLock(OldIrql);*/
|
||||
|
||||
TI_DbgPrint(DEBUG_IRP, ("Leaving.\n"));
|
||||
}
|
||||
|
||||
|
||||
VOID DispDataRequestComplete(
|
||||
PVOID Context,
|
||||
NTSTATUS Status,
|
||||
|
@ -155,8 +127,6 @@ VOID DispDoDisconnect( PVOID Data ) {
|
|||
TI_DbgPrint(DEBUG_IRP, ("PostCancel: DoDisconnect done\n"));
|
||||
|
||||
DispDataRequestComplete(DisType->Irp, STATUS_CANCELLED, 0);
|
||||
|
||||
DispCancelComplete(DisType->FileObject);
|
||||
}
|
||||
|
||||
VOID NTAPI DispCancelRequest(
|
||||
|
@ -209,24 +179,20 @@ VOID NTAPI DispCancelRequest(
|
|||
if( !ChewCreate( &WorkItem, sizeof(DISCONNECT_TYPE),
|
||||
DispDoDisconnect, &DisType ) )
|
||||
ASSERT(0);
|
||||
break;
|
||||
return;
|
||||
|
||||
case TDI_SEND_DATAGRAM:
|
||||
if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
|
||||
TI_DbgPrint(MIN_TRACE, ("TDI_SEND_DATAGRAM, but no address file.\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
/*DGCancelSendRequest(TranContext->Handle.AddressHandle, Irp);*/
|
||||
break;
|
||||
|
||||
case TDI_RECEIVE_DATAGRAM:
|
||||
if (FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) {
|
||||
TI_DbgPrint(MIN_TRACE, ("TDI_RECEIVE_DATAGRAM, but no address file.\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
/*DGCancelReceiveRequest(TranContext->Handle.AddressHandle, Irp);*/
|
||||
DGRemoveIRP(TranContext->Handle.AddressHandle, Irp);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -235,6 +201,7 @@ VOID NTAPI DispCancelRequest(
|
|||
}
|
||||
|
||||
IoReleaseCancelSpinLock(Irp->CancelIrql);
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
|
||||
}
|
||||
|
@ -280,8 +247,6 @@ VOID NTAPI DispCancelListenRequest(
|
|||
|
||||
DispDataRequestComplete(Irp, STATUS_CANCELLED, 0);
|
||||
|
||||
DispCancelComplete(FileObject);
|
||||
|
||||
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,6 @@ CP
|
|||
}
|
||||
CP
|
||||
Context->CancelIrps = FALSE;
|
||||
KeInitializeEvent(&Context->CleanupEvent, NotificationEvent, FALSE);
|
||||
CP
|
||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
IrpSp->FileObject->FsContext = Context;
|
||||
|
@ -253,36 +252,6 @@ CP
|
|||
return Status;
|
||||
}
|
||||
|
||||
|
||||
VOID TiCleanupFileObjectComplete(
|
||||
PVOID Context,
|
||||
NTSTATUS Status)
|
||||
/*
|
||||
* FUNCTION: Completes an object cleanup IRP I/O request
|
||||
* ARGUMENTS:
|
||||
* Context = Pointer to the IRP for this request
|
||||
* Status = Final status of the operation
|
||||
*/
|
||||
{
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
PTRANSPORT_CONTEXT TranContext;
|
||||
KIRQL OldIrql;
|
||||
|
||||
Irp = (PIRP)Context;
|
||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
TranContext = (PTRANSPORT_CONTEXT)IrpSp->FileObject->FsContext;
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
|
||||
IoAcquireCancelSpinLock(&OldIrql);
|
||||
|
||||
KeSetEvent(&TranContext->CleanupEvent, 0, FALSE);
|
||||
|
||||
IoReleaseCancelSpinLock(OldIrql);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* FUNCTION: Releases resources used by a file object
|
||||
* ARGUMENTS:
|
||||
|
@ -313,13 +282,9 @@ NTSTATUS TiCleanupFileObject(
|
|||
IoAcquireCancelSpinLock(&OldIrql);
|
||||
|
||||
Context->CancelIrps = TRUE;
|
||||
KeResetEvent(&Context->CleanupEvent);
|
||||
|
||||
IoReleaseCancelSpinLock(OldIrql);
|
||||
|
||||
Request.RequestNotifyObject = TiCleanupFileObjectComplete;
|
||||
Request.RequestContext = Irp;
|
||||
|
||||
switch ((ULONG_PTR)IrpSp->FileObject->FsContext2) {
|
||||
case TDI_TRANSPORT_ADDRESS_FILE:
|
||||
Request.Handle.AddressHandle = Context->Handle.AddressHandle;
|
||||
|
@ -345,19 +310,8 @@ NTSTATUS TiCleanupFileObject(
|
|||
Context->CancelIrps = FALSE;
|
||||
IoReleaseCancelSpinLock(OldIrql);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
|
||||
return Irp->IoStatus.Status;
|
||||
}
|
||||
|
||||
if (Status != STATUS_PENDING)
|
||||
{
|
||||
IoAcquireCancelSpinLock(&OldIrql);
|
||||
KeSetEvent(&Context->CleanupEvent, 0, FALSE);
|
||||
IoReleaseCancelSpinLock(OldIrql);
|
||||
|
||||
KeWaitForSingleObject(&Context->CleanupEvent,
|
||||
UserRequest, KernelMode, FALSE, NULL);
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
|
|
Loading…
Reference in a new issue