about summary refs log tree commit diff
path: root/sunrpc
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-04-14 23:49:40 +0000
committerUlrich Drepper <drepper@redhat.com>1999-04-14 23:49:40 +0000
commitea48e2c4cc0b0a5e09e9407c9309d4a85926e8b7 (patch)
tree56f88f516b741d852200b86b6c2dc9ecb785dd6a /sunrpc
parent613ae2c8ee6e332a6963d9960518d36e8cc312c3 (diff)
downloadglibc-ea48e2c4cc0b0a5e09e9407c9309d4a85926e8b7.tar.gz
glibc-ea48e2c4cc0b0a5e09e9407c9309d4a85926e8b7.tar.xz
glibc-ea48e2c4cc0b0a5e09e9407c9309d4a85926e8b7.zip
Update.
1999-04-14  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* wctype/test_wcfuncs.c: New file, tests towlower and towupper.
	* wctype/Makefile (tests): Add test_wcfuncs.
Diffstat (limited to 'sunrpc')
-rw-r--r--sunrpc/clnt_udp.c38
1 files changed, 37 insertions, 1 deletions
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 <netdb.h>
 #include <errno.h>
 #include <rpc/pmap_clnt.h>
+#include <net/if.h>
 
 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)