From: Andrew Deason Date: Tue, 11 Sep 2012 17:56:22 +0000 (-0500) Subject: rx: Split out rxi_NetSendError X-Git-Tag: upstream/1.8.0_pre1^2~1976 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=27ee85123284b77004c757fec7cd6c9af3078e05;p=packages%2Fo%2Fopenafs.git rx: Split out rxi_NetSendError This logic is duplicated in a couple of places. Just extract it into its own little function for easier modification. Change-Id: Iebcc460698beaee6f1cee4b4fb633b9a10e37213 Reviewed-on: http://gerrit.openafs.org/8109 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/rx/rx_packet.c b/src/rx/rx_packet.c index d0cb5d3ec..89d9183d4 100644 --- a/src/rx/rx_packet.c +++ b/src/rx/rx_packet.c @@ -2143,6 +2143,31 @@ rxi_SendDebugPacket(struct rx_packet *apacket, osi_socket asocket, } +static void +rxi_NetSendError(struct rx_call *call, int code) +{ + int down = 0; +#ifdef AFS_NT40_ENV + if (code == -1 && WSAGetLastError() == WSAEHOSTUNREACH) { + down = 1; + } + if (code == -WSAEHOSTUNREACH) { + down = 1; + } +#elif defined(AFS_LINUX20_ENV) + if (code == -ENETUNREACH) { + down = 1; + } +#elif defined(AFS_DARWIN_ENV) + if (code == EHOSTUNREACH) { + down = 1; + } +#endif + if (down) { + call->lastReceiveTime = 0; + } +} + /* Send the packet to appropriate destination for the specified * call. The header is first encoded and placed in the packet. */ @@ -2259,18 +2284,9 @@ rxi_SendPacket(struct rx_call *call, struct rx_connection *conn, * So, when this happens let's "down" the host NOW so * we don't sit around waiting for this host to timeout later. */ - if (call && -#ifdef AFS_NT40_ENV - (code == -1 && WSAGetLastError() == WSAEHOSTUNREACH) || (code == -WSAEHOSTUNREACH) -#elif defined(AFS_LINUX20_ENV) - code == -ENETUNREACH -#elif defined(AFS_DARWIN_ENV) - code == EHOSTUNREACH -#else - 0 -#endif - ) - call->lastReceiveTime = 0; + if (call) { + rxi_NetSendError(call, code); + } } #ifdef KERNEL #ifdef RX_KERNEL_TRACE @@ -2469,18 +2485,9 @@ rxi_SendPacketList(struct rx_call *call, struct rx_connection *conn, * So, when this happens let's "down" the host NOW so * we don't sit around waiting for this host to timeout later. */ - if (call && -#ifdef AFS_NT40_ENV - (code == -1 && WSAGetLastError() == WSAEHOSTUNREACH) || (code == -WSAEHOSTUNREACH) -#elif defined(AFS_LINUX20_ENV) - code == -ENETUNREACH -#elif defined(AFS_DARWIN_ENV) - code == EHOSTUNREACH -#else - 0 -#endif - ) - call->lastReceiveTime = 0; + if (call) { + rxi_NetSendError(call, code); + } } #if defined(AFS_SUN5_ENV) && defined(KERNEL) if (!istack && waslocked)