Author: cgutman
Date: Sat Aug 15 04:09:23 2009
New Revision: 42673
URL:
http://svn.reactos.org/svn/reactos?rev=42673&view=rev
Log:
- Fix several bugs in select code and remove some dead code
- Fix a typo
- Part 1 of x
Modified:
trunk/reactos/drivers/network/afd/afd/connect.c
trunk/reactos/drivers/network/afd/afd/listen.c
trunk/reactos/drivers/network/afd/afd/main.c
trunk/reactos/drivers/network/afd/afd/read.c
trunk/reactos/drivers/network/afd/afd/select.c
trunk/reactos/drivers/network/afd/afd/write.c
trunk/reactos/drivers/network/afd/include/afd.h
Modified: trunk/reactos/drivers/network/afd/afd/connect.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/co…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/connect.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/connect.c [iso-8859-1] Sat Aug 15 04:09:23 2009
@@ -63,6 +63,9 @@
if( Status == STATUS_PENDING ) Status = STATUS_SUCCESS;
+ FCB->PollState |= AFD_EVENT_CONNECT | AFD_EVENT_SEND;
+ PollReeval( FCB->DeviceExt, FCB->FileObject );
+
return Status;
}
@@ -102,17 +105,12 @@
return STATUS_FILE_CLOSED;
}
- if( NT_SUCCESS(Irp->IoStatus.Status) ) {
- FCB->PollState |= AFD_EVENT_CONNECT | AFD_EVENT_SEND;
- AFD_DbgPrint(MID_TRACE,("Going to connected state %d\n", FCB->State));
- FCB->State = SOCKET_STATE_CONNECTED;
- } else {
- FCB->PollState |= AFD_EVENT_CONNECT_FAIL | AFD_EVENT_RECEIVE;
+ if( !NT_SUCCESS(Irp->IoStatus.Status) ) {
+ FCB->PollState |= AFD_EVENT_CONNECT_FAIL;
AFD_DbgPrint(MID_TRACE,("Going to bound state\n"));
FCB->State = SOCKET_STATE_BOUND;
- }
-
- PollReeval( FCB->DeviceExt, FCB->FileObject );
+ PollReeval( FCB->DeviceExt, FCB->FileObject );
+ }
/* Succeed pending irps on the FUNCTION_CONNECT list */
while( !IsListEmpty( &FCB->PendingIrpList[FUNCTION_CONNECT] ) ) {
Modified: trunk/reactos/drivers/network/afd/afd/listen.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/li…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/listen.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/listen.c [iso-8859-1] Sat Aug 15 04:09:23 2009
@@ -36,11 +36,6 @@
else
Status = MakeSocketIntoConnection( FCB );
- if( NT_SUCCESS(Status) ) {
- FCB->PollState |= AFD_EVENT_SEND;
- PollReeval( DeviceExt, NewFileObject );
- }
-
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
}
@@ -192,8 +187,11 @@
/* Trigger a select return if appropriate */
if( !IsListEmpty( &FCB->PendingConnections ) ) {
FCB->PollState |= AFD_EVENT_ACCEPT;
- PollReeval( FCB->DeviceExt, FCB->FileObject );
- }
+ } else {
+ FCB->PollState &= ~AFD_EVENT_ACCEPT;
+ }
+
+ PollReeval( FCB->DeviceExt, FCB->FileObject );
SocketStateUnlock( FCB );
@@ -296,7 +294,11 @@
AFD_DbgPrint(MID_TRACE,("Completed a wait for accept\n"));
- FCB->PollState &= ~AFD_EVENT_ACCEPT;
+ if ( IsListEmpty( &FCB->PendingConnections ) )
+ FCB->PollState &= ~AFD_EVENT_ACCEPT;
+ else
+ FCB->PollState |= AFD_EVENT_ACCEPT;
+
PollReeval( FCB->DeviceExt, FCB->FileObject );
SocketStateUnlock( FCB );
@@ -322,8 +324,6 @@
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
- FCB->EventsFired &= ~AFD_EVENT_ACCEPT;
-
if( FCB->NeedsNewListen ) {
AFD_DbgPrint(MID_TRACE,("ADDRESSFILE: %x\n", FCB->AddressFile.Handle));
@@ -412,8 +412,11 @@
if( IsListEmpty( &FCB->PendingConnections ) ) {
FCB->PollState &= ~AFD_EVENT_ACCEPT;
- PollReeval( FCB->DeviceExt, FCB->FileObject );
- }
+ } else {
+ FCB->PollState |= AFD_EVENT_ACCEPT;
+ }
+
+ PollReeval( FCB->DeviceExt, FCB->FileObject );
SocketStateUnlock( FCB );
return Status;
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] Sat Aug 15 04:09:23 2009
@@ -300,6 +300,9 @@
if (ConnInfo) ExFreePool( ConnInfo );
+ FCB->PollState |= AFD_EVENT_DISCONNECT;
+ PollReeval( FCB->DeviceExt, FCB->FileObject );
+
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
}
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] Sat Aug 15 04:09:23 2009
@@ -303,9 +303,6 @@
Irp, 0 );
}
- FCB->EventsFired &= ~AFD_EVENT_RECEIVE;
- PollReeval( FCB->DeviceExt, FCB->FileObject );
-
if( !(RecvReq = LockRequest( Irp, IrpSp )) )
return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY,
Irp, 0 );
@@ -332,7 +329,7 @@
Status = ReceiveActivity( FCB, Irp );
- if( Status == STATUS_PENDING && RecvReq->AfdFlags & AFD_IMMEDIATE ) {
+ if( Status == STATUS_PENDING && (RecvReq->AfdFlags & AFD_IMMEDIATE) )
{
AFD_DbgPrint(MID_TRACE,("Nonblocking\n"));
Status = STATUS_CANT_WAIT;
TotalBytesCopied = 0;
@@ -595,8 +592,6 @@
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
- FCB->EventsFired &= ~AFD_EVENT_RECEIVE;
-
/* Check that the socket is bound */
if( FCB->State != SOCKET_STATE_BOUND )
return UnlockAndMaybeComplete
@@ -660,10 +655,12 @@
} else if( RecvReq->AfdFlags & AFD_IMMEDIATE ) {
AFD_DbgPrint(MID_TRACE,("Nonblocking\n"));
Status = STATUS_CANT_WAIT;
+ FCB->PollState &= ~AFD_EVENT_RECEIVE;
PollReeval( FCB->DeviceExt, FCB->FileObject );
UnlockBuffers( RecvReq->BufferArray, RecvReq->BufferCount, TRUE );
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
} else {
+ FCB->PollState &= ~AFD_EVENT_RECEIVE;
PollReeval( FCB->DeviceExt, FCB->FileObject );
return LeaveIrpUntilLater( FCB, Irp, FUNCTION_RECV );
}
Modified: trunk/reactos/drivers/network/afd/afd/select.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/se…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/select.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/select.c [iso-8859-1] Sat Aug 15 04:09:23 2009
@@ -205,23 +205,16 @@
FileObject = (PFILE_OBJECT)AFD_HANDLES(PollReq)[i].Handle;
FCB = FileObject->FsContext;
- if( (FCB->PollState & AFD_EVENT_CLOSE) ||
- (PollReq->Handles[i].Status & AFD_EVENT_CLOSE) ) {
- PollReq->Handles[i].Events = 0;
- PollReq->Handles[i].Status = AFD_EVENT_CLOSE;
- Signalled++;
- } else {
- AFD_DbgPrint(MID_TRACE, ("AFD: Select Events: "));
- PrintEvents( PollReq->Handles[i].Events );
- AFD_DbgPrint(MID_TRACE,("\n"));
-
- PollReq->Handles[i].Status =
+ AFD_DbgPrint(MID_TRACE, ("AFD: Select Events: "));
+ PrintEvents( PollReq->Handles[i].Events );
+ AFD_DbgPrint(MID_TRACE,("\n"));
+
+ PollReq->Handles[i].Status =
PollReq->Handles[i].Events & FCB->PollState;
- if( PollReq->Handles[i].Status ) {
+ if( PollReq->Handles[i].Status ) {
AFD_DbgPrint(MID_TRACE,("Signalling %x with %x\n",
FCB, FCB->PollState));
Signalled++;
- }
}
}
@@ -286,7 +279,6 @@
EventSelectInfo->EventObject,
EventSelectInfo->Events));
- FCB->EventSelectTriggers = FCB->EventsFired = 0;
if( FCB->EventSelect ) ObDereferenceObject( FCB->EventSelect );
FCB->EventSelect = NULL;
@@ -303,8 +295,8 @@
FCB->EventSelect = NULL;
else
FCB->EventSelectTriggers = EventSelectInfo->Events;
- } else /* Work done, cancelling select */
- Status = STATUS_SUCCESS;
+ } else
+ Status = STATUS_INVALID_PARAMETER;
AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
@@ -370,7 +362,6 @@
PAFD_FCB FCB;
KIRQL OldIrql;
PAFD_POLL_INFO PollReq;
- PKEVENT EventSelect = NULL;
AFD_DbgPrint(MID_TRACE,("Called: DeviceExt %x FileObject %x\n",
DeviceExt, FileObject));
@@ -383,16 +374,6 @@
if( !FCB ) {
KeReleaseSpinLock( &DeviceExt->Lock, OldIrql );
return;
- }
-
- /* Not sure if i can do this at DISPATCH_LEVEL ... try it at passive */
- AFD_DbgPrint(MID_TRACE,("Current State: %x, Events Fired: %x, "
- "Select Triggers %x\n",
- FCB->PollState, FCB->EventsFired,
- FCB->EventSelectTriggers));
- if( FCB->PollState & ~FCB->EventsFired & FCB->EventSelectTriggers )
{
- FCB->EventsFired |= FCB->PollState;
- EventSelect = FCB->EventSelect;
}
/* Now signal normal select irps */
@@ -413,8 +394,10 @@
KeReleaseSpinLock( &DeviceExt->Lock, OldIrql );
- AFD_DbgPrint(MID_TRACE,("Setting event %x\n", EventSelect));
- if( EventSelect ) KeSetEvent( EventSelect, IO_NETWORK_INCREMENT, FALSE );
+ if( FCB->EventSelect && (FCB->PollState &
FCB->EventSelectTriggers) ) {
+ AFD_DbgPrint(MID_TRACE,("Setting event %x\n", FCB->EventSelect));
+ KeSetEvent( FCB->EventSelect, IO_NETWORK_INCREMENT, FALSE );
+ }
AFD_DbgPrint(MID_TRACE,("Leaving\n"));
}
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] Sat Aug 15 04:09:23 2009
@@ -223,8 +223,6 @@
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
- FCB->EventsFired &= ~AFD_EVENT_SEND;
-
if( FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS )
{
PAFD_SEND_INFO_UDP SendReq;
@@ -393,7 +391,6 @@
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
- FCB->EventsFired &= ~AFD_EVENT_SEND;
FCB->PollState &= ~AFD_EVENT_SEND;
PollReeval( FCB->DeviceExt, FCB->FileObject );
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] Sat Aug 15 04:09:23 2009
@@ -196,7 +196,6 @@
KEVENT StateLockedEvent;
PKEVENT EventSelect;
DWORD EventSelectTriggers;
- DWORD EventsFired;
UNICODE_STRING TdiDeviceName;
PVOID Context;
DWORD PollState;