Author: cgutman
Date: Fri Jul 22 15:11:01 2011
New Revision: 52783
URL:
http://svn.reactos.org/svn/reactos?rev=52783&view=rev
Log:
[AFD]
- Fix (hopefully) the final disconnect bugs
Modified:
trunk/reactos/drivers/network/afd/afd/main.c
trunk/reactos/drivers/network/afd/afd/read.c
trunk/reactos/drivers/network/afd/afd/write.c
trunk/reactos/drivers/network/afd/include/afd.h
Modified: trunk/reactos/drivers/network/afd/afd/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/ma…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/main.c [iso-8859-1] Fri Jul 22 15:11:01 2011
@@ -603,12 +603,13 @@
IoCompleteRequest(CurrentIrp, IO_NETWORK_INCREMENT );
}
- if (FCB->DisconnectFlags & TDI_DISCONNECT_RELEASE)
- FCB->PollState |= AFD_EVENT_DISCONNECT;
- else
+ if (!(FCB->DisconnectFlags & TDI_DISCONNECT_RELEASE))
+ {
+ /* Signal complete connection closure immediately */
FCB->PollState |= AFD_EVENT_ABORT;
- FCB->PollStatus[FD_CLOSE_BIT] = Irp->IoStatus.Status;
- PollReeval(FCB->DeviceExt, FCB->FileObject);
+ FCB->PollStatus[FD_CLOSE_BIT] = Irp->IoStatus.Status;
+ PollReeval(FCB->DeviceExt, FCB->FileObject);
+ }
SocketStateUnlock(FCB);
@@ -721,6 +722,7 @@
FCB->DisconnectFlags = Flags;
FCB->DisconnectTimeout = DisReq->Timeout;
FCB->DisconnectPending = TRUE;
+ FCB->SendClosed = TRUE;
Status = QueueUserModeIrp(FCB, Irp, FUNCTION_DISCONNECT);
if (Status == STATUS_PENDING)
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] Fri Jul 22 15:11:01 2011
@@ -32,8 +32,8 @@
{
FCB->TdiReceiveClosed = TRUE;
- /* Signal unexpected termination immediately */
- FCB->PollState |= AFD_EVENT_ABORT;
+ /* Signal complete connection failure immediately */
+ FCB->PollState |= AFD_EVENT_CLOSE;
FCB->PollStatus[FD_CLOSE_BIT] = Status;
PollReeval( FCB->DeviceExt, FCB->FileObject );
@@ -232,13 +232,12 @@
PollReeval( FCB->DeviceExt, FCB->FileObject );
}
else if (CantReadMore(FCB) &&
- !(FCB->PollState & (AFD_EVENT_ABORT | AFD_EVENT_CLOSE)) &&
- IsListEmpty(&FCB->PendingIrpList[FUNCTION_RECV]))
+ !(FCB->PollState & (AFD_EVENT_CLOSE | AFD_EVENT_ABORT)))
{
FCB->PollState &= ~AFD_EVENT_RECEIVE;
- /* Signal delayed close event */
- FCB->PollState |= AFD_EVENT_ABORT;
+ /* Signal graceful receive shutdown */
+ FCB->PollState |= AFD_EVENT_DISCONNECT;
FCB->PollStatus[FD_CLOSE_BIT] = STATUS_SUCCESS;
PollReeval( FCB->DeviceExt, FCB->FileObject );
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] Fri Jul 22 15:11:01 2011
@@ -351,26 +351,28 @@
}
}
- if (FCB->DisconnectPending && (FCB->DisconnectFlags &
TDI_DISCONNECT_RELEASE))
+ if (FCB->PollState & AFD_EVENT_CLOSE)
+ {
+ AFD_DbgPrint(MIN_TRACE,("Connection reset by remote peer\n"));
+
+ /* This is an unexpected remote disconnect */
+ return UnlockAndMaybeComplete(FCB, FCB->PollStatus[FD_CLOSE_BIT], Irp, 0);
+ }
+
+ if (FCB->PollState & AFD_EVENT_ABORT)
+ {
+ AFD_DbgPrint(MIN_TRACE,("Connection aborted\n"));
+
+ /* This is an abortive socket closure on our side */
+ return UnlockAndMaybeComplete(FCB, FCB->PollStatus[FD_CLOSE_BIT], Irp, 0);
+ }
+
+ if (FCB->SendClosed)
{
AFD_DbgPrint(MIN_TRACE,("No more sends\n"));
- /* We're pending a send shutdown so don't accept anymore sends */
+
+ /* This is a graceful send closure */
return UnlockAndMaybeComplete(FCB, STATUS_FILE_CLOSED, Irp, 0);
- }
-
- if (FCB->PollState & (AFD_EVENT_CLOSE | AFD_EVENT_DISCONNECT))
- {
- AFD_DbgPrint(MIN_TRACE,("No more sends\n"));
- 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 )) )
Modified: trunk/reactos/drivers/network/afd/include/afd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/includ…
==============================================================================
--- trunk/reactos/drivers/network/afd/include/afd.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/include/afd.h [iso-8859-1] Fri Jul 22 15:11:01 2011
@@ -173,7 +173,7 @@
} AFD_STORED_DATAGRAM, *PAFD_STORED_DATAGRAM;
typedef struct _AFD_FCB {
- BOOLEAN Locked, Critical, Overread, NonBlocking, OobInline, TdiReceiveClosed;
+ BOOLEAN Locked, Critical, Overread, NonBlocking, OobInline, TdiReceiveClosed,
SendClosed;
UINT State, Flags, GroupID, GroupType;
KIRQL OldIrql;
UINT LockCount;