- Fix several bugs so select() will now recognize when a connection gets closed
authorCameron Gutman <aicommander@gmail.com>
Fri, 14 Aug 2009 00:09:59 +0000 (00:09 +0000)
committerCameron Gutman <aicommander@gmail.com>
Fri, 14 Aug 2009 00:09:59 +0000 (00:09 +0000)
svn path=/trunk/; revision=42661

reactos/dll/win32/msafd/misc/dllmain.c
reactos/dll/win32/msafd/misc/event.c
reactos/drivers/network/afd/afd/main.c
reactos/drivers/network/afd/afd/select.c

index 2573ac5..66136cb 100644 (file)
@@ -777,6 +777,7 @@ WSPSelect(int nfds,
             PollInfo->Handles[j].Events = AFD_EVENT_RECEIVE |
                                           AFD_EVENT_DISCONNECT |
                                           AFD_EVENT_ABORT |
+                                          AFD_EVENT_CLOSE |
                                           AFD_EVENT_ACCEPT;
         }
     }
@@ -2397,7 +2398,7 @@ VOID SockProcessAsyncSelect(PSOCKET_INFORMATION Socket, PASYNC_DATA AsyncData)
 
     if (lNetworkEvents & FD_CLOSE)
     {
-        AsyncData->AsyncSelectInfo.Handles[0].Events |= AFD_EVENT_DISCONNECT | AFD_EVENT_ABORT;
+        AsyncData->AsyncSelectInfo.Handles[0].Events |= AFD_EVENT_DISCONNECT | AFD_EVENT_ABORT | AFD_EVENT_CLOSE;
     }
 
     if (lNetworkEvents & FD_QOS)
index 9719258..9a49e31 100644 (file)
@@ -76,7 +76,7 @@ WSPEventSelect(
     }
 
     if (lNetworkEvents & FD_CLOSE) {
-       EventSelectInfo.Events |= AFD_EVENT_DISCONNECT | AFD_EVENT_ABORT;
+       EventSelectInfo.Events |= AFD_EVENT_DISCONNECT | AFD_EVENT_ABORT | AFD_EVENT_CLOSE;
     }
 
     if (lNetworkEvents & FD_QOS) {
@@ -206,7 +206,7 @@ WSPEnumNetworkEvents(
     }
 
     if (EnumReq.PollEvents & 
-       (AFD_EVENT_DISCONNECT | AFD_EVENT_ABORT)) {
+       (AFD_EVENT_DISCONNECT | AFD_EVENT_ABORT | AFD_EVENT_CLOSE)) {
        lpNetworkEvents->lNetworkEvents |= FD_CLOSE;
     }
 
index 866d0eb..3ab4983 100644 (file)
@@ -184,6 +184,8 @@ AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
     if( !SocketAcquireStateLock( FCB ) ) return STATUS_FILE_CLOSED;
 
     FCB->State = SOCKET_STATE_CLOSED;
+    FCB->PollState = AFD_EVENT_CLOSE;
+    PollReeval( FCB->DeviceExt, FCB->FileObject );
 
     InFlightRequest[0] = &FCB->ListenIrp;
     InFlightRequest[1] = &FCB->ReceiveIrp;
index 1c045d4..010c816 100644 (file)
@@ -145,7 +145,7 @@ VOID KillSelectsForFCB( PAFD_DEVICE_EXTENSION DeviceExt,
             if( (PVOID)HandleArray[i].Handle == FileObject &&
                 (!OnlyExclusive || (OnlyExclusive && Poll->Exclusive)) ) {
                 ZeroEvents( PollReq->Handles, PollReq->HandleCount );
-                SignalSocket( Poll, NULL, PollReq, STATUS_SUCCESS );
+                SignalSocket( Poll, NULL, PollReq, STATUS_CANCELLED );
             }
        }
     }
@@ -353,20 +353,11 @@ static BOOLEAN UpdatePollWithFCB( PAFD_ACTIVE_POLL Poll, PFILE_OBJECT FileObject
        FileObject = (PFILE_OBJECT)AFD_HANDLES(PollReq)[i].Handle;
        FCB = FileObject->FsContext;
 
-       if( (FCB->PollState & AFD_EVENT_CLOSE) ||
-           (PollReq->Handles[i].Status & AFD_EVENT_CLOSE) ) {
-           AFD_HANDLES(PollReq)[i].Handle = 0;
-           PollReq->Handles[i].Events = 0;
-           PollReq->Handles[i].Status = AFD_EVENT_CLOSE;
-           Signalled++;
-       } else {
-           PollReq->Handles[i].Status =
-               PollReq->Handles[i].Events & FCB->PollState;
-           if( PollReq->Handles[i].Status ) {
-               AFD_DbgPrint(MID_TRACE,("Signalling %x with %x\n",
+       PollReq->Handles[i].Status = PollReq->Handles[i].Events & FCB->PollState;
+       if( PollReq->Handles[i].Status ) {
+           AFD_DbgPrint(MID_TRACE,("Signalling %x with %x\n",
                                        FCB, FCB->PollState));
-               Signalled++;
-           }
+           Signalled++;
        }
     }