Author: cgutman
Date: Tue Aug 2 13:46:16 2011
New Revision: 53028
URL:
http://svn.reactos.org/svn/reactos?rev=53028&view=rev
Log:
[AFD]
- Handle TDI receive completion better
Modified:
trunk/reactos/drivers/network/afd/afd/read.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 Aug 2 13:46:16 2011
@@ -23,22 +23,38 @@
*/
#include "afd.h"
-static VOID HandleEOFOnIrp( PAFD_FCB FCB, NTSTATUS Status, ULONG_PTR Information )
+static VOID HandleReceiveComplete( PAFD_FCB FCB, NTSTATUS Status, ULONG_PTR Information
)
{
- if (Status != STATUS_SUCCESS)
- {
+ FCB->Recv.BytesUsed = 0;
+
+ /* Receive successful with new data */
+ if (Status == STATUS_SUCCESS && Information)
+ {
+ FCB->Recv.Content = Information;
+ }
+ /* Receive successful with no data (graceful closure) */
+ else if (Status == STATUS_SUCCESS)
+ {
+ FCB->Recv.Content = 0;
FCB->TdiReceiveClosed = TRUE;
-
+
+ /* Signal graceful receive shutdown */
+ FCB->PollState |= AFD_EVENT_DISCONNECT;
+ FCB->PollStatus[FD_CLOSE_BIT] = Status;
+
+ PollReeval( FCB->DeviceExt, FCB->FileObject );
+ }
+ /* Receive failed with no data (unexpected closure) */
+ else
+ {
+ FCB->Recv.Content = 0;
+ FCB->TdiReceiveClosed = TRUE;
+
/* Signal complete connection failure immediately */
FCB->PollState |= AFD_EVENT_CLOSE;
FCB->PollStatus[FD_CLOSE_BIT] = Status;
PollReeval( FCB->DeviceExt, FCB->FileObject );
- }
- else if (Status == STATUS_SUCCESS && !Information)
- {
- /* Wait to signal graceful close until all data is read */
- FCB->TdiReceiveClosed = TRUE;
}
}
@@ -228,17 +244,6 @@
FCB->PollStatus[FD_READ_BIT] = STATUS_SUCCESS;
PollReeval( FCB->DeviceExt, FCB->FileObject );
}
- else if (CantReadMore(FCB) &&
- !(FCB->PollState & (AFD_EVENT_CLOSE | AFD_EVENT_ABORT)))
- {
- FCB->PollState &= ~AFD_EVENT_RECEIVE;
-
- /* Signal graceful receive shutdown */
- FCB->PollState |= AFD_EVENT_DISCONNECT;
- FCB->PollStatus[FD_CLOSE_BIT] = STATUS_SUCCESS;
-
- PollReeval( FCB->DeviceExt, FCB->FileObject );
- }
else
{
FCB->PollState &= ~AFD_EVENT_RECEIVE;
@@ -272,9 +277,6 @@
ASSERT(FCB->ReceiveIrp.InFlightRequest == Irp);
FCB->ReceiveIrp.InFlightRequest = NULL;
-
- FCB->Recv.Content = Irp->IoStatus.Information;
- FCB->Recv.BytesUsed = 0;
if( FCB->State == SOCKET_STATE_CLOSED ) {
/* Cleanup our IRP queue because the FCB is being destroyed */
@@ -298,7 +300,7 @@
return STATUS_INVALID_PARAMETER;
}
- HandleEOFOnIrp( FCB, Irp->IoStatus.Status, Irp->IoStatus.Information );
+ HandleReceiveComplete( FCB, Irp->IoStatus.Status, Irp->IoStatus.Information );
ReceiveActivity( FCB, NULL );