Author: cgutman
Date: Tue Jun 21 13:59:49 2011
New Revision: 52402
URL:
http://svn.reactos.org/svn/reactos?rev=52402&view=rev
Log:
[AFD]
- Remove extra cruft around the TdiReceive call
- Handle send and receive requests better after a socket closure
Modified:
trunk/reactos/drivers/network/afd/afd/read.c
trunk/reactos/drivers/network/afd/afd/write.c
Modified: trunk/reactos/drivers/network/afd/afd/read.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/re…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/read.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/read.c [iso-8859-1] Tue Jun 21 13:59:49 2011
@@ -47,24 +47,18 @@
}
static VOID RefillSocketBuffer( PAFD_FCB FCB ) {
- NTSTATUS Status;
-
if( !FCB->ReceiveIrp.InFlightRequest &&
!(FCB->PollState & (AFD_EVENT_CLOSE | AFD_EVENT_ABORT)) ) {
AFD_DbgPrint(MID_TRACE,("Replenishing buffer\n"));
- Status = TdiReceive( &FCB->ReceiveIrp.InFlightRequest,
- FCB->Connection.Object,
- TDI_RECEIVE_NORMAL,
- FCB->Recv.Window,
- FCB->Recv.Size,
- &FCB->ReceiveIrp.Iosb,
- ReceiveComplete,
- FCB );
- if (Status != STATUS_PENDING)
- {
- HandleEOFOnIrp(FCB, Status, FCB->ReceiveIrp.Iosb.Information);
- }
+ TdiReceive( &FCB->ReceiveIrp.InFlightRequest,
+ FCB->Connection.Object,
+ TDI_RECEIVE_NORMAL,
+ FCB->Recv.Window,
+ FCB->Recv.Size,
+ &FCB->ReceiveIrp.Iosb,
+ ReceiveComplete,
+ FCB );
}
}
@@ -163,12 +157,23 @@
TotalBytesCopied));
UnlockBuffers( RecvReq->BufferArray,
RecvReq->BufferCount, FALSE );
- Status = NextIrp->IoStatus.Status = FCB->PollStatus[FD_CLOSE_BIT];
+ if (FCB->Overread && FCB->PollStatus[FD_CLOSE_BIT] ==
STATUS_SUCCESS)
+ {
+ /* Overread after a graceful disconnect so complete with an error */
+ Status = STATUS_FILE_CLOSED;
+ }
+ else
+ {
+ /* Unexpected disconnect by the remote host or initial read after a
graceful disconnnect */
+ Status = FCB->PollStatus[FD_CLOSE_BIT];
+ }
+ NextIrp->IoStatus.Status = Status;
NextIrp->IoStatus.Information = 0;
if( NextIrp == Irp ) RetStatus = Status;
if( NextIrp->MdlAddress ) UnlockRequest( NextIrp,
IoGetCurrentIrpStackLocation( NextIrp ) );
(void)IoSetCancelRoutine(NextIrp, NULL);
IoCompleteRequest( NextIrp, IO_NETWORK_INCREMENT );
+ FCB->Overread = TRUE;
}
} else {
/* Kick the user that receive would be possible now */
Modified: trunk/reactos/drivers/network/afd/afd/write.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/wr…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/write.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/write.c [iso-8859-1] Tue Jun 21 13:59:49 2011
@@ -286,6 +286,20 @@
UnlockBuffers(SendReq->BufferArray, SendReq->BufferCount, FALSE);
return UnlockAndMaybeComplete( FCB, Status, Irp, Information );
}
+
+ if (FCB->PollState & (AFD_EVENT_CLOSE | AFD_EVENT_DISCONNECT))
+ {
+ if (FCB->PollStatus[FD_CLOSE_BIT] == STATUS_SUCCESS)
+ {
+ /* This is a local send shutdown or a graceful remote disconnect */
+ return UnlockAndMaybeComplete(FCB, STATUS_FILE_CLOSED, Irp, 0);
+ }
+ else
+ {
+ /* This is an unexpected remote disconnect */
+ return UnlockAndMaybeComplete(FCB, FCB->PollStatus[FD_CLOSE_BIT], Irp,
0);
+ }
+ }
if( !(SendReq = LockRequest( Irp, IrpSp )) )
return UnlockAndMaybeComplete