[OSKITTCP]
authorCameron Gutman <aicommander@gmail.com>
Sat, 2 Jul 2011 21:47:30 +0000 (21:47 +0000)
committerCameron Gutman <aicommander@gmail.com>
Sat, 2 Jul 2011 21:47:30 +0000 (21:47 +0000)
- Signal readable when read is closed and writeable when write is closed
- This seems counterintuitive on the surface but signaling the socket in this way ensures that pending reads and writes are cancelled if either side shuts down send/receive
- Graceful close (recv() returns 0 bytes and FD_CLOSE is signaled when we receive a FIN) works much better

svn path=/trunk/; revision=52504

reactos/lib/drivers/oskittcp/oskittcp/sleep.c

index 0fcc7c9..a15154e 100644 (file)
@@ -31,13 +31,13 @@ void wakeup( struct socket *so, void *token ) {
        OS_DbgPrint(OSK_MID_TRACE,("Socket accepting q\n"));
        flags |= SEL_ACCEPT;
     }
-    if( so->so_rcv.sb_cc > 0 && !(so->so_state & SS_CANTRCVMORE) &&
-        (so->so_state & SS_ISCONNECTED) ) {
+    if( (so->so_rcv.sb_cc > 0 && (so->so_state & SS_ISCONNECTED)) ||
+         (so->so_state & SS_CANTRCVMORE)) {
        OS_DbgPrint(OSK_MID_TRACE,("Socket readable\n"));
        flags |= SEL_READ;
     }
-    if( 0 < sbspace(&so->so_snd) && !(so->so_state & SS_CANTSENDMORE) &&
-        (so->so_state & SS_ISCONNECTED) ) {
+    if( (0 < sbspace(&so->so_snd) && (so->so_state & SS_ISCONNECTED)) ||
+         (so->so_state & SS_CANTSENDMORE)) {
        OS_DbgPrint(OSK_MID_TRACE,("Socket writeable\n"));
        flags |= SEL_WRITE;
     }