From 119c756d96c4a7f9e01e4ff6bb20156f1abf761b Mon Sep 17 00:00:00 2001 From: Adam Megacz Date: Sun, 19 Jul 2009 11:00:41 -0700 Subject: [PATCH] Use -errno or WSAGetLastError() as return value from rxi_Sendmsg() 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 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 Reviewed-by: Adam Megacz Tested-by: Adam Megacz Reviewed-by: Derrick Brashear --- src/rx/rx_lwp.c | 7 +++++++ src/rx/rx_pthread.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/rx/rx_lwp.c b/src/rx/rx_lwp.c index a476609cf..2020c4154 100644 --- a/src/rx/rx_lwp.c +++ b/src/rx/rx_lwp.c @@ -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) { diff --git a/src/rx/rx_pthread.c b/src/rx/rx_pthread.c index 40507fbf6..eb4f0e0f4 100644 --- a/src/rx/rx_pthread.c +++ b/src/rx/rx_pthread.c @@ -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; -- 2.39.5