From ea48e2c4cc0b0a5e09e9407c9309d4a85926e8b7 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 14 Apr 1999 23:49:40 +0000 Subject: Update. 1999-04-14 Andreas Jaeger * wctype/test_wcfuncs.c: New file, tests towlower and towupper. * wctype/Makefile (tests): Add test_wcfuncs. --- sunrpc/clnt_udp.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'sunrpc') diff --git a/sunrpc/clnt_udp.c b/sunrpc/clnt_udp.c index ec63f60f8e..35ac684955 100644 --- a/sunrpc/clnt_udp.c +++ b/sunrpc/clnt_udp.c @@ -48,6 +48,7 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; #include #include #include +#include extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); extern u_long _create_xid (void); @@ -214,6 +215,33 @@ clntudp_create (raddr, program, version, wait, sockp) UDPMSGSIZE, UDPMSGSIZE); } +static int +is_network_up (int sock) +{ + struct ifconf ifc; + char buf[UDPMSGSIZE]; + struct ifreq ifreq, *ifr; + int n; + + ifc.ifc_len = sizeof (buf); + ifc.ifc_buf = buf; + if (__ioctl(sock, SIOCGIFCONF, (char *) &ifc) == 0) + { + ifr = ifc.ifc_req; + for (n = ifc.ifc_len / sizeof (struct ifreq); n > 0; n--, ifr++) + { + ifreq = *ifr; + if (__ioctl (sock, SIOCGIFFLAGS, (char *) &ifreq) < 0) + break; + + if ((ifreq.ifr_flags & IFF_UP) + && ifr->ifr_addr.sa_family == AF_INET) + return 1; + } + } + return 0; +} + static enum clnt_stat clntudp_call (cl, proc, xargs, argsp, xresults, resultsp, utimeout) CLIENT *cl; /* client handle */ @@ -239,6 +267,7 @@ clntudp_call (cl, proc, xargs, argsp, xresults, resultsp, utimeout) bool_t ok; int nrefreshes = 2; /* number of times to refresh cred */ struct timeval timeout; + int anyup; /* any network interface up */ if (cu->cu_total.tv_usec == -1) { @@ -296,10 +325,17 @@ send_again: fd.events = POLLIN; for (;;) { - switch (__poll(&fd, 1, milliseconds)) + switch (__poll (&fd, 1, milliseconds)) { case 0: + if (anyup == 0) + { + anyup = is_network_up (cu->cu_sock); + if (!anyup) + return (cu->cu_error.re_status = RPC_CANTRECV); + } + time_waited.tv_sec += cu->cu_wait.tv_sec; time_waited.tv_usec += cu->cu_wait.tv_usec; while (time_waited.tv_usec >= 1000000) -- cgit 1.4.1