]> git.puffer.fish Git - mirror/frr.git/commitdiff
[zebra] do not touch socket before pidfile locking
authorDenis Ovsienko <pilot@etcnet.org>
Fri, 24 Jul 2009 16:45:31 +0000 (20:45 +0400)
committerDenis Ovsienko <pilot@etcnet.org>
Fri, 24 Jul 2009 16:45:31 +0000 (20:45 +0400)
Move zserv socket creation code into zebra_zserv_socket_init() and
call it only after pidfile lock has been acquired exclusively. This
keeps subsequent zebra daemons from deleting the working socket of
an already running process (bug #403).

zebra/main.c
zebra/zserv.c
zebra/zserv.h

index 14b0273cb74463e5fda5eb4e3b9df7b26c4d528a..2d6a4ac865fb9a553c2401670036ae8bc186baa8 100644 (file)
@@ -382,6 +382,9 @@ main (int argc, char **argv)
   /* Needed for BSD routing socket. */
   pid = getpid ();
 
+  /* This must be done only after locking pidfile (bug #403). */
+  zebra_zserv_socket_init ();
+
   /* Make vty server socket. */
   vty_serv_sock (vty_addr, vty_port, ZEBRA_VTYSH_PATH);
 
index a566e6d42106a58922abacf314df24c666c03b36..cb5e411cf720781d99244306d1ac1a5cb5ee0a14 100644 (file)
@@ -1704,13 +1704,6 @@ zebra_init (void)
   /* Client list init. */
   zebrad.client_list = list_new ();
 
-  /* Make zebra server socket. */
-#ifdef HAVE_TCP_ZEBRA
-  zebra_serv ();
-#else
-  zebra_serv_un (ZEBRA_SERV_PATH);
-#endif /* HAVE_TCP_ZEBRA */
-
   /* Install configuration write function. */
   install_node (&table_node, config_write_table);
   install_node (&forwarding_node, config_write_forwarding);
@@ -1737,3 +1730,14 @@ zebra_init (void)
   /* Route-map */
   zebra_route_map_init ();
 }
+
+/* Make zebra server socket, wiping any existing one (see bug #403). */
+void
+zebra_zserv_socket_init (void)
+{
+#ifdef HAVE_TCP_ZEBRA
+  zebra_serv ();
+#else
+  zebra_serv_un (ZEBRA_SERV_PATH);
+#endif /* HAVE_TCP_ZEBRA */
+}
index 87a33a4550efb422d295130f20853b800b1955a2..a737183047186ba2c22d3b171040ad075f3f4a66 100644 (file)
@@ -89,6 +89,7 @@ struct zebra_t
 /* Prototypes. */
 extern void zebra_init (void);
 extern void zebra_if_init (void);
+extern void zebra_zserv_socket_init (void);
 extern void hostinfo_get (void);
 extern void rib_init (void);
 extern void interface_list (void);