]> git.proxmox.com Git - mirror_frr.git/blobdiff - watchquagga/watchquagga.c
bgp: missing pieces from listener patch
[mirror_frr.git] / watchquagga / watchquagga.c
index 772b4294cd65fa04a50b0d03bac44dd8825b983f..f4c483cf428a9719eadac46b933b698abd4f4b9d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    $Id: watchquagga.c,v 1.9 2005/01/12 16:24:51 ajs Exp $
+    $Id$
 
     Monitor status of quagga daemons and restart if necessary.
 
@@ -23,6 +23,7 @@
 #include <zebra.h>
 #include <thread.h>
 #include <log.h>
+#include <network.h>
 #include <sigevent.h>
 #include <lib/version.h>
 #include <getopt.h>
@@ -608,7 +609,7 @@ handle_read(struct thread *t_read)
     {
       char why[100];
 
-      if ((errno == EINTR) || (errno == EAGAIN))
+      if (ERRNO_IO_RETRY(errno))
        {
          /* Pretend it never happened. */
          SET_READ_HANDLER(dmn);
@@ -733,7 +734,6 @@ try_connect(struct daemon *dmn)
   int sock;
   struct sockaddr_un addr;
   socklen_t len;
-  int flags;
 
   if (gs.loglevel > LOG_DEBUG+1)
     zlog_debug("%s: attempting to connect",dmn->name);
@@ -743,11 +743,11 @@ try_connect(struct daemon *dmn)
   addr.sun_family = AF_UNIX;
   snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s.vty",
           gs.vtydir,dmn->name);
-#ifdef HAVE_SUN_LEN
+#ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
   len = addr.sun_len = SUN_LEN(&addr);
 #else
   len = sizeof (addr.sun_family) + strlen (addr.sun_path);
-#endif /* HAVE_SUN_LEN */
+#endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */
 
   /* Quick check to see if we might succeed before we go to the trouble
      of creating a socket. */
@@ -766,18 +766,10 @@ try_connect(struct daemon *dmn)
       return -1;
     }
 
-  /* Set non-blocking. */
-  if ((flags = fcntl(sock, F_GETFL, 0)) < 0)
+  if (set_nonblocking(sock) < 0)
     {
-      zlog_err("%s(%s): fcntl(F_GETFL) failed: %s",
-              __func__,addr.sun_path, safe_strerror(errno));
-      close(sock);
-      return -1;
-    }
-  if (fcntl(sock, F_SETFL, (flags|O_NONBLOCK)) < 0)
-    {
-      zlog_err("%s(%s): fcntl(F_SETFL,O_NONBLOCK) failed: %s",
-              __func__,addr.sun_path, safe_strerror(errno));
+      zlog_err("%s(%s): set_nonblocking(%d) failed",
+              __func__, addr.sun_path, sock);
       close(sock);
       return -1;
     }