]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
rx: Save errno in LWP rxi_Sendmsg
authorAndrew Deason <adeason@sinenomine.net>
Tue, 11 Sep 2012 23:46:42 +0000 (18:46 -0500)
committerStephan Wiesand <stephan.wiesand@desy.de>
Fri, 22 Mar 2013 14:07:42 +0000 (07:07 -0700)
Much of this code examines errno or WSAGetLastError to determine what
to do. However, some other operations between the actual sendmsg call
and code that examines errno may modify errno. So, save the value of
errno to ensure errno reflects the actual error we got from sendmsg;
this also slightly simplifies some of the logic.

Reviewed-on: http://gerrit.openafs.org/8110
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 347908cd0031c558c266ec412aa49200ae2b3204)

Change-Id: Ia0134acb2ae5f9e47fb82f36bd0889987803d897
Reviewed-on: http://gerrit.openafs.org/9496
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/rx/rx_lwp.c

index 525743edc69ed645ce612031c392477c86560b82..929c90fe90197b9e0ab70112acf938e609dc12f2 100644 (file)
@@ -434,6 +434,13 @@ rxi_Sendmsg(osi_socket socket, struct msghdr *msg_p, int flags)
     fd_set *sfds = (fd_set *) 0;
     while (sendmsg(socket, msg_p, flags) == -1) {
        int err;
+
+#ifdef AFS_NT40_ENV
+       err = WSAGetLastError();
+#else
+       err = errno;
+#endif
+
        rx_stats.sendSelects++;
 
        if (!sfds) {
@@ -449,26 +456,21 @@ rxi_Sendmsg(osi_socket socket, struct msghdr *msg_p, int flags)
          ;
 #endif
 #ifdef AFS_NT40_ENV
-       if (WSAGetLastError())
+       if (err)
 #elif defined(AFS_LINUX22_ENV)
        /* linux unfortunately returns ECONNREFUSED if the target port
         * is no longer in use */
        /* and EAGAIN if a UDP checksum is incorrect */
-       if (errno != EWOULDBLOCK && errno != ENOBUFS && errno != ECONNREFUSED
-           && errno != EAGAIN)
+       if (err != EWOULDBLOCK && err != ENOBUFS && err != ECONNREFUSED
+           && err != EAGAIN)
 #else
-       if (errno != EWOULDBLOCK && errno != ENOBUFS)
+       if (err != EWOULDBLOCK && err != ENOBUFS)
 #endif
        {
            (osi_Msg "rx failed to send packet: ");
            perror("rx_sendmsg");
-#ifndef AFS_NT40_ENV
-            if (errno > 0)
-              return -errno;
-#else
-            if (WSAGetLastError() > 0)
-              return -WSAGetLastError();
-#endif
+            if (err > 0)
+              return -err;
            return -1;
        }
        while ((err = select(socket + 1, 0, sfds, 0, 0)) != 1) {