win32-ewouldblock-20040602
authorJeffrey Altman <jaltman@mit.edu>
Wed, 2 Jun 2004 15:50:23 +0000 (15:50 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 2 Jun 2004 15:50:23 +0000 (15:50 +0000)
 * enable detection of EWOULDBLOCK errors on Windows

src/rx/rx_packet.c
src/rx/rx_xmit_nt.c

index 682af93..f7a2859 100644 (file)
@@ -64,6 +64,9 @@ RCSID
 #if defined(AFS_NT40_ENV) || defined(AFS_DJGPP_ENV)
 #ifdef AFS_NT40_ENV
 #include <winsock2.h>
+#ifndef EWOULDBLOCK
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#endif
 #else
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -826,13 +829,11 @@ rxi_ReadPacket(int socket, register struct rx_packet *p, afs_uint32 * host,
     if ((nbytes > tlen) || (p->length & 0x8000)) {     /* Bogus packet */
        if (nbytes > 0)
            rxi_MorePackets(rx_initSendWindow);
-#ifndef AFS_NT40_ENV
        else if (nbytes < 0 && errno == EWOULDBLOCK) {
            MUTEX_ENTER(&rx_stats_mutex);
            rx_stats.noPacketOnRead++;
            MUTEX_EXIT(&rx_stats_mutex);
        }
-#endif
        else {
            MUTEX_ENTER(&rx_stats_mutex);
            rx_stats.bogusPacketOnRead++;
index f8ce9a3..4c56679 100644 (file)
@@ -78,6 +78,14 @@ recvmsg(int socket, struct msghdr *msgP, int flags)
        /* Accounts for any we didn't copy in to iovecs. */
        code -= size;
     } else {
+#ifdef AFS_NT40_ENV
+    if (code == SOCKET_ERROR)
+        code = WSAGetLastError();
+    if (code == WSAEWOULDBLOCK)
+        errno = WSAEWOULDBLOCK;
+    else
+        errno = EIO;
+#endif /* AFS_NT40_ENV */
        code = -1;
     }
 
@@ -125,10 +133,12 @@ sendmsg(int socket, struct msghdr *msgP, int flags)
        switch (code) {
        case WSAEINPROGRESS:
        case WSAENETRESET:
-       case WSAEWOULDBLOCK:
        case WSAENOBUFS:
            errno = 0;
            break;
+    case WSAEWOULDBLOCK:
+        errno = WSAEWOULDBLOCK;
+        break;
        default:
            errno = EIO;
            break;
@@ -145,8 +155,4 @@ sendmsg(int socket, struct msghdr *msgP, int flags)
     return code;
 
 }
-
-
-
-
 #endif /* AFS_NT40_ENV || AFS_DJGPP_ENV */