Use -errno or WSAGetLastError() as return value from rxi_Sendmsg()
authorAdam Megacz <megacz@hcoop.net>
Sun, 19 Jul 2009 18:00:41 +0000 (11:00 -0700)
committerDerrick Brashear <shadow@dementia.org>
Mon, 27 Jul 2009 01:00:22 +0000 (18:00 -0700)
This patch causes the pthread and lwp implementations of rxi_Sendmsg()
to use -errno or WSAGetLastError() as the return value if it is
positive.  This is required in order to communicate more meaningful
error conditions to rxi_SendPacket[List], which should "down" a host
immediately when it observes ENETUNREACH.

Jeff Altman <jaltman@openafs.org> supplied the logic for the
AFS_NT40_ENV case; I was not able to test this (I do not own a
Windows license) and took him on his word.

Reviewed-on: http://gerrit.openafs.org/58
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Adam Megacz <megacz@gmail.com>
Tested-by: Adam Megacz <megacz@gmail.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

src/rx/rx_lwp.c
src/rx/rx_pthread.c

index a476609..2020c41 100644 (file)
@@ -460,6 +460,13 @@ rxi_Sendmsg(osi_socket socket, struct msghdr *msg_p, int flags)
        {
            (osi_Msg "rx failed to send packet: ");
            perror("rx_sendmsg");
+#ifndef AFS_NT40_ENV
+            if (errno > 0)
+              return -errno;
+#elif
+            if (WSAGetLastError() > 0)
+              return -WSAGetLastError();
+#endif
            return -1;
        }
        while ((err = select(socket + 1, 0, sfds, 0, 0)) != 1) {
index 40507fb..eb4f0e0 100644 (file)
@@ -440,6 +440,13 @@ rxi_Sendmsg(osi_socket socket, struct msghdr *msg_p, int flags)
 #endif
        dpf(("rxi_sendmsg failed, error %d\n", errno));
        fflush(stdout);
+#ifndef AFS_NT40_ENV
+        if (errno > 0)
+          return -errno;
+#elif
+            if (WSAGetLastError() > 0)
+              return -WSAGetLastError();
+#endif
        return -1;
     }
     return 0;