Commit in reactos/lib/msafd on MAIN
include/msafd.h+61.12 -> 1.13
misc/dllmain.c+71-11.31 -> 1.32
    /sndrcv.c+18-21.17 -> 1.18
+95-3
3 modified files
Fully support AsyncSelect by re-enabling events. Also, FD_CONNECT stuff isn't quite right, I need to investigate more.

reactos/lib/msafd/include
msafd.h 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- msafd.h	19 Dec 2004 20:13:28 -0000	1.12
+++ msafd.h	27 Dec 2004 21:18:05 -0000	1.13
@@ -460,6 +460,12 @@
 	PIO_STATUS_BLOCK IoStatusBlock
 );
 
+VOID
+SockReenableAsyncSelectEvent (
+    IN PSOCKET_INFORMATION Socket,
+    IN ULONG Event
+    );
+    
 DWORD MsafdReturnWithErrno( NTSTATUS Status, LPINT Errno, DWORD Received,
 			    LPDWORD ReturnedBytes );
 

reactos/lib/msafd/misc
dllmain.c 1.31 -> 1.32
diff -u -r1.31 -r1.32
--- dllmain.c	26 Dec 2004 15:04:33 -0000	1.31
+++ dllmain.c	27 Dec 2004 21:18:07 -0000	1.32
@@ -974,6 +974,9 @@
 					sizeof(RemoteAddress));
 
 	NtClose( SockEvent );
+ 
+    /* Re-enable Async Event */
+    SockReenableAsyncSelectEvent(Socket, FD_ACCEPT);
 
 	AFD_DbgPrint(MID_TRACE,("Socket %x\n", AcceptSocket));
 
@@ -1054,6 +1057,16 @@
 					SocketAddress->sa_data, 
 					SocketAddressLength - sizeof(SocketAddress->sa_family));
 
+    /* 
+     * Disable FD_WRITE and FD_CONNECT 
+     * The latter fixes a race condition where the FD_CONNECT is re-enabled
+     * at the end of this function right after the Async Thread disables it.
+     * This should only happen at the *next* WSPConnect
+     */
+    if (Socket->SharedData.AsyncEvents & FD_CONNECT) {
+        Socket->SharedData.AsyncDisabledEvents |= FD_CONNECT | FD_WRITE;
+    }
+    
 	/* Tell AFD that we want Connection Data back, have it allocate a buffer */
 	if (lpCalleeData != NULL) {
 		InConnectDataLength = lpCalleeData->len;
@@ -1074,6 +1087,11 @@
 	ConnectInfo->UseSAN = FALSE;
 	ConnectInfo->Unknown = 0;
 
+    /* FIXME: Handle Async Connect */
+    if (Socket->SharedData.NonBlocking) {
+        AFD_DbgPrint(MIN_TRACE, ("Async Connect UNIMPLEMENTED!\n"));
+    }
+               
 	/* Send IOCTL */
 	Status = NtDeviceIoControlFile((HANDLE)Handle,
 									SockEvent,
@@ -1100,6 +1118,12 @@
 										lpCalleeData->len);
 	 }
 
+    /* Re-enable Async Event */
+    SockReenableAsyncSelectEvent(Socket, FD_WRITE);
+    
+    /* FIXME: THIS IS NOT RIGHT!!! HACK HACK HACK! */
+    SockReenableAsyncSelectEvent(Socket, FD_CONNECT);
+    
 	AFD_DbgPrint(MID_TRACE,("Ending\n"));
 
 	NtClose( SockEvent );
@@ -1717,7 +1741,6 @@
 		return;
 	}
 
-
 	for (x = 1; x; x<<=1) {
 		switch (AsyncData->AsyncSelectInfo.Handles[0].Events & x) {
 			case AFD_EVENT_RECEIVE:
@@ -1756,6 +1779,7 @@
 				}
 				break;
 
+            /* FIXME: THIS IS NOT RIGHT!!! HACK HACK HACK! */
 			case AFD_EVENT_CONNECT:
 				if (0 != (Socket->SharedData.AsyncEvents & FD_CONNECT) && 0 == (Socket->SharedData.AsyncDisabledEvents & FD_CONNECT)) {
 					/* Make the Notifcation */
@@ -1842,6 +1866,7 @@
 		AsyncData->AsyncSelectInfo.Handles[0].Events |= AFD_EVENT_ACCEPT;
 	}
 
+     /* FIXME: THIS IS NOT RIGHT!!! HACK HACK HACK! */
 	if (lNetworkEvents & FD_CONNECT) {
 		AsyncData->AsyncSelectInfo.Handles[0].Events |= AFD_EVENT_CONNECT | AFD_EVENT_CONNECT_FAIL;
 	}
@@ -1908,6 +1933,51 @@
 	return;
 }
 
+VOID
+SockReenableAsyncSelectEvent (
+    IN PSOCKET_INFORMATION Socket,
+    IN ULONG Event
+    )
+{
+    PASYNC_DATA AsyncData;
+
+    /* Make sure the event is actually disabled */
+    if (!(Socket->SharedData.AsyncDisabledEvents & Event)) {
+        return;
+    }
+
+    /* Re-enable it */
+    Socket->SharedData.AsyncDisabledEvents &= ~Event;
+
+    /* Return if no more events are being polled */
+    if ((Socket->SharedData.AsyncEvents & (~Socket->SharedData.AsyncDisabledEvents)) == 0 ) {
+        return;
+    }
+
+    /* Wait on new events */
+    AsyncData = HeapAlloc(GetProcessHeap(), 0, sizeof(ASYNC_DATA));
+
+    /* Create the Asynch Thread if Needed */  
+    SockCreateOrReferenceAsyncThread();
+
+    /* Increase the sequence number to stop anything else */
+    Socket->SharedData.SequenceNumber++;
+    
+    /* Set up the Async Data */
+    AsyncData->ParentSocket = Socket;
+    AsyncData->SequenceNumber = Socket->SharedData.SequenceNumber;
+
+    /* Begin Async Select by using I/O Completion */
+    NtSetIoCompletion(SockAsyncCompletionPort,
+                      (PVOID)&SockProcessQueuedAsyncSelect,
+                      AsyncData,
+                      0,
+                      0);
+    
+    /* All done */
+    return;
+}
+
 BOOL
 STDCALL
 DllMain(HANDLE hInstDll,

reactos/lib/msafd/misc
sndrcv.c 1.17 -> 1.18
diff -u -r1.17 -r1.18
--- sndrcv.c	27 Dec 2004 10:38:06 -0000	1.17
+++ sndrcv.c	27 Dec 2004 21:18:07 -0000	1.18
@@ -58,7 +58,7 @@
 	Socket->SharedData.AsyncDisabledEvents = 0;
 	Socket->SharedData.SequenceNumber++;
 
-        /* Return if there are no more Events */
+    /* Return if there are no more Events */
 	if ((Socket->SharedData.AsyncEvents & (~Socket->SharedData.AsyncDisabledEvents)) == 0) {
 		HeapFree(GetProcessHeap(), 0, AsyncData);
 		return 0;
@@ -76,7 +76,7 @@
 				  0);
 
 	/* Return */
-	return 0;
+	return ERROR_SUCCESS;
 }
 
 
@@ -207,6 +207,13 @@
 	*ReceiveFlags = MSG_PARTIAL | MSG_OOB; break;
     case STATUS_RECEIVE_PARTIAL: *ReceiveFlags = MSG_PARTIAL; break;
     }
+    
+    /* Re-enable Async Event */
+    if (*ReceiveFlags == MSG_OOB) {
+        SockReenableAsyncSelectEvent(Socket, FD_OOB);
+    } else {
+        SockReenableAsyncSelectEvent(Socket, FD_READ);
+    }
 
     return MsafdReturnWithErrno
 	( Status, lpErrno, IOSB->Information, lpNumberOfBytesRead );
@@ -337,6 +344,9 @@
     case STATUS_RECEIVE_PARTIAL: *ReceiveFlags = MSG_PARTIAL; break;
     }
 
+    /* Re-enable Async Event */
+    SockReenableAsyncSelectEvent(Socket, FD_READ);
+    
     return MsafdReturnWithErrno
 	( Status, lpErrno, IOSB->Information, lpNumberOfBytesRead );
 }
@@ -448,6 +458,9 @@
 	    return WSA_IO_PENDING;
 	}
 
+     /* Re-enable Async Event */
+    SockReenableAsyncSelectEvent(Socket, FD_WRITE);
+    
 	AFD_DbgPrint(MID_TRACE,("Leaving (Success, %d)\n", IOSB->Information));
 
     return MsafdReturnWithErrno
@@ -572,6 +585,9 @@
 	if (Status == STATUS_PENDING) {
         return WSA_IO_PENDING;
 	}
+ 
+    /* Re-enable Async Event */
+    SockReenableAsyncSelectEvent(Socket, FD_WRITE);
 
     return MsafdReturnWithErrno
 	( Status, lpErrno, IOSB->Information, lpNumberOfBytesSent );
CVSspam 0.2.8