Author: cgutman
Date: Wed Aug 20 09:43:33 2008
New Revision: 35478
URL:
http://svn.reactos.org/svn/reactos?rev=35478&view=rev
Log:
- The rest of the merge
- This will most likely need fixing later
Modified:
branches/aicom-network-fixes/drivers/network/afd/afd/main.c
branches/aicom-network-fixes/drivers/network/afd/afd/read.c
branches/aicom-network-fixes/drivers/network/tcpip/tcpip/dispatch.c
branches/aicom-network-fixes/drivers/network/tcpip/tcpip/main.c
Modified: branches/aicom-network-fixes/drivers/network/afd/afd/main.c
URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
==============================================================================
--- branches/aicom-network-fixes/drivers/network/afd/afd/main.c [iso-8859-1] (original)
+++ branches/aicom-network-fixes/drivers/network/afd/afd/main.c [iso-8859-1] Wed Aug 20
09:43:33 2008
@@ -153,52 +153,7 @@
}
VOID DestroySocket( PAFD_FCB FCB ) {
- UINT i;
- BOOLEAN ReturnEarly = FALSE;
- PAFD_IN_FLIGHT_REQUEST InFlightRequest[IN_FLIGHT_REQUESTS];
-
AFD_DbgPrint(MIN_TRACE,("Called (%x)\n", FCB));
-
- if( !SocketAcquireStateLock( FCB ) ) return;
-
- FCB->State = SOCKET_STATE_CLOSED;
-
- InFlightRequest[0] = &FCB->ListenIrp;
- InFlightRequest[1] = &FCB->ReceiveIrp;
- InFlightRequest[2] = &FCB->SendIrp;
- InFlightRequest[3] = &FCB->ConnectIrp;
-
- /* Return early here because we might be called in the mean time. */
- if( FCB->Critical ||
- FCB->ListenIrp.InFlightRequest ||
- FCB->ReceiveIrp.InFlightRequest ||
- FCB->SendIrp.InFlightRequest ||
- FCB->ConnectIrp.InFlightRequest ) {
- AFD_DbgPrint(MIN_TRACE,("Leaving socket alive (%x %x %x %x)\n",
- FCB->ListenIrp.InFlightRequest,
- FCB->ReceiveIrp.InFlightRequest,
- FCB->SendIrp.InFlightRequest,
- FCB->ConnectIrp.InFlightRequest));
- ReturnEarly = TRUE;
- }
-
- /* After PoolReeval, this FCB should not be involved in any outstanding
- * poll requests */
-
- /* Cancel our pending requests */
- for( i = 0; i < IN_FLIGHT_REQUESTS; i++ ) {
- 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 );
- }
- }
-
- SocketStateUnlock( FCB );
-
- if( ReturnEarly ) return;
if( FCB->Recv.Window )
ExFreePool( FCB->Recv.Window );
@@ -227,8 +182,12 @@
AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
PIO_STACK_LOCATION IrpSp)
{
+ UINT i;
+ AFD_IN_FLIGHT_REQUEST InFlightRequest[IN_FLIGHT_REQUESTS];
PFILE_OBJECT FileObject = IrpSp->FileObject;
PAFD_FCB FCB = FileObject->FsContext;
+
+ if (!SocketAcquireStateLock(FCB)) return LostSocket(Irp, FALSE);
AFD_DbgPrint(MID_TRACE,
("AfdClose(DeviceObject %p Irp %p)\n", DeviceObject, Irp));
@@ -242,15 +201,56 @@
if( FCB->EventSelect ) ObDereferenceObject( FCB->EventSelect );
FileObject->FsContext = NULL;
+
+ FCB->State = SOCKET_STATE_CLOSED;
+ SocketStateUnlock(FCB);
+
+ InFlightRequest[0] = FCB->ListenIrp;
+ InFlightRequest[1] = FCB->ReceiveIrp;
+ InFlightRequest[2] = FCB->SendIrp;
+
+ /* Return early here because we might be called in the mean time. */
+ if( !(FCB->Critical ||
+ FCB->ListenIrp.InFlightRequest ||
+ FCB->ReceiveIrp.InFlightRequest ||
+ FCB->SendIrp.InFlightRequest) ) {
+ AFD_DbgPrint(MIN_TRACE,("Leaving socket alive (%x %x %x)\n",
+ FCB->ListenIrp.InFlightRequest,
+ FCB->ReceiveIrp.InFlightRequest,
+ FCB->SendIrp.InFlightRequest));
+ SocketStateUnlock(FCB);
+ DestroySocket(FCB);
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ }
+ else
+ {
+ /* After PoolReeval, this FCB should not be involved in any outstanding
+ * poll requests */
+
+ /* Cancel our pending requests */
+ for( i = 0; i < IN_FLIGHT_REQUESTS; i++ ) {
+ NTSTATUS Status = STATUS_NO_SUCH_FILE;
+ 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;
+ InFlightRequest[i].InFlightRequest->IoStatus.Information = 0;
+ IoCancelIrp( InFlightRequest[i].InFlightRequest );
+ }
+ }
+
+ FCB->PendingClose = Irp;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ }
+
DestroySocket( FCB );
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
AFD_DbgPrint(MID_TRACE, ("Returning success.\n"));
- return STATUS_SUCCESS;
+ return Irp->IoStatus.Status;
}
static NTSTATUS STDCALL
Modified: branches/aicom-network-fixes/drivers/network/afd/afd/read.c
URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
==============================================================================
--- branches/aicom-network-fixes/drivers/network/afd/afd/read.c [iso-8859-1] (original)
+++ branches/aicom-network-fixes/drivers/network/afd/afd/read.c [iso-8859-1] Wed Aug 20
09:43:33 2008
@@ -242,7 +242,6 @@
if( FCB->State == SOCKET_STATE_CLOSED ) {
AFD_DbgPrint(MIN_TRACE,("!!! CLOSED SOCK GOT A RECEIVE COMPLETE
!!!\n"));
SocketStateUnlock( FCB );
- DestroySocket( FCB );
return STATUS_SUCCESS;
} else if( FCB->State == SOCKET_STATE_LISTENING ) {
AFD_DbgPrint(MIN_TRACE,("!!! LISTENER GOT A RECEIVE COMPLETE !!!\n"));
@@ -453,9 +452,10 @@
FCB->ReceiveIrp.InFlightRequest = NULL;
+ if( !SocketAcquireStateLock( FCB ) ) return STATUS_UNSUCCESSFUL;
+
if( FCB->State == SOCKET_STATE_CLOSED ) {
SocketStateUnlock( FCB );
- DestroySocket( FCB );
return STATUS_SUCCESS;
}
Modified: branches/aicom-network-fixes/drivers/network/tcpip/tcpip/dispatch.c
URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
==============================================================================
--- branches/aicom-network-fixes/drivers/network/tcpip/tcpip/dispatch.c [iso-8859-1]
(original)
+++ branches/aicom-network-fixes/drivers/network/tcpip/tcpip/dispatch.c [iso-8859-1] Wed
Aug 20 09:43:33 2008
@@ -52,34 +52,6 @@
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,
@@ -155,8 +127,14 @@
TI_DbgPrint(DEBUG_IRP, ("PostCancel: DoDisconnect done\n"));
DispDataRequestComplete(DisType->Irp, STATUS_CANCELLED, 0);
-
- DispCancelComplete(DisType->FileObject);
+}
+
+VOID DispDoPacketCancel( PVOID Data ) {
+ TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
+ PIRP *IrpP = (PIRP *)Data, Irp = *IrpP;
+ Irp->IoStatus.Status = STATUS_CANCELLED;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
VOID NTAPI DispCancelRequest(
@@ -175,6 +153,7 @@
UCHAR MinorFunction;
DISCONNECT_TYPE DisType;
PVOID WorkItem;
+ PADDRESS_FILE AddrFile;
/*NTSTATUS Status = STATUS_SUCCESS;*/
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
@@ -209,24 +188,23 @@
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);*/
+ /* Nothing to do. We don't keep them around. */
break;
case TDI_RECEIVE_DATAGRAM:
+ AddrFile = (PADDRESS_FILE)TranContext->Handle.AddressHandle;
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(AddrFile, Irp);
break;
default:
@@ -235,7 +213,8 @@
}
IoReleaseCancelSpinLock(Irp->CancelIrql);
-
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
}
@@ -279,9 +258,6 @@
IoReleaseCancelSpinLock(Irp->CancelIrql);
DispDataRequestComplete(Irp, STATUS_CANCELLED, 0);
-
- DispCancelComplete(FileObject);
-
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
}
@@ -817,7 +793,6 @@
return Status;
}
-
NTSTATUS DispTdiReceiveDatagram(
PIRP Irp)
/*
@@ -834,6 +809,7 @@
TDI_REQUEST Request;
NTSTATUS Status;
ULONG BytesReceived;
+ PADDRESS_FILE AddrFile;
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
@@ -847,6 +823,8 @@
return STATUS_INVALID_ADDRESS;
}
+ AddrFile = (PADDRESS_FILE)TranContext->Handle.AddressHandle;
+
/* Initialize a receive request */
Request.Handle.AddressHandle = TranContext->Handle.AddressHandle;
Request.RequestNotifyObject = DispDataRequestComplete;
@@ -866,21 +844,21 @@
&DataBuffer,
&BufferSize );
- Status = DGReceiveDatagram(
- Request.Handle.AddressHandle,
- DgramInfo->ReceiveDatagramInformation,
- DataBuffer,
- DgramInfo->ReceiveLength,
- DgramInfo->ReceiveFlags,
- DgramInfo->ReturnDatagramInformation,
- &BytesReceived,
- (PDATAGRAM_COMPLETION_ROUTINE)DispDataRequestComplete,
- Irp,
- Irp);
- if (Status != STATUS_PENDING) {
- DispDataRequestComplete(Irp, Status, BytesReceived);
- } else
- IoMarkIrpPending(Irp);
+ Status = DGReceiveDatagram(
+ AddrFile,
+ DgramInfo->ReceiveDatagramInformation,
+ DataBuffer,
+ DgramInfo->ReceiveLength,
+ DgramInfo->ReceiveFlags,
+ DgramInfo->ReturnDatagramInformation,
+ &BytesReceived,
+ (PDATAGRAM_COMPLETION_ROUTINE)DispDataRequestComplete,
+ Irp,
+ Irp);
+ if (Status != STATUS_PENDING) {
+ DispDataRequestComplete(Irp, Status, BytesReceived);
+ } else
+ IoMarkIrpPending(Irp);
}
TI_DbgPrint(DEBUG_IRP, ("Leaving. Status is (0x%X)\n", Status));
Modified: branches/aicom-network-fixes/drivers/network/tcpip/tcpip/main.c
URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/drivers/net…
==============================================================================
--- branches/aicom-network-fixes/drivers/network/tcpip/tcpip/main.c [iso-8859-1]
(original)
+++ branches/aicom-network-fixes/drivers/network/tcpip/tcpip/main.c [iso-8859-1] Wed Aug
20 09:43:33 2008
@@ -138,7 +138,6 @@
}
CP
Context->CancelIrps = FALSE;
- KeInitializeEvent(&Context->CleanupEvent, NotificationEvent, FALSE);
CP
IrpSp = IoGetCurrentIrpStackLocation(Irp);
IrpSp->FileObject->FsContext = Context;
@@ -266,20 +265,11 @@
{
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);
}
@@ -313,7 +303,6 @@
IoAcquireCancelSpinLock(&OldIrql);
Context->CancelIrps = TRUE;
- KeResetEvent(&Context->CleanupEvent);
IoReleaseCancelSpinLock(OldIrql);
@@ -348,16 +337,6 @@
Irp->IoStatus.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;