]> 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)
committerDerrick Brashear <shadow@your-file-system.com>
Tue, 25 Sep 2012 03:43:06 +0000 (20:43 -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.

Change-Id: I5a8643fce5d2e29131069743b14805bbc2428805
Reviewed-on: http://gerrit.openafs.org/8110
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
src/rx/rx_lwp.c

index e6ae068e12b1a3448a27b0a36edf0a39d57289a9..fe9bdceef03e8e72b98b28ea33a503a3d0c6e1bc 100644 (file)
@@ -429,6 +429,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
+
        if (rx_stats_active)
            rx_atomic_inc(&rx_stats.sendSelects);
 
@@ -445,26 +452,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(