ofp-print: Print OFPUTIL_NXST_AGGREGATE_REPLY.
[openvswitch] / lib / daemon.c
index bc28973fc6a2d3d62c3aa7c270659387b8e3f0e1..c0f168291e6ed053540e9260ec8e6997d4b8d4a3 100644 (file)
@@ -35,7 +35,7 @@
 #include "util.h"
 #include "vlog.h"
 
-VLOG_DEFINE_THIS_MODULE(daemon)
+VLOG_DEFINE_THIS_MODULE(daemon);
 
 /* --detach: Should we run in the background? */
 static bool detach;
@@ -67,8 +67,8 @@ char *
 make_pidfile_name(const char *name)
 {
     return (!name
-            ? xasprintf("%s/%s.pid", ovs_rundir, program_name)
-            : abs_file_name(ovs_rundir, name));
+            ? xasprintf("%s/%s.pid", ovs_rundir(), program_name)
+            : abs_file_name(ovs_rundir(), name));
 }
 
 /* Sets up a following call to daemonize() to create a pidfile named 'name'.
@@ -367,13 +367,13 @@ monitor_daemon(pid_t daemon_pid)
             ovs_fatal(errno, "waitpid failed");
         } else if (retval == daemon_pid) {
             char *s = process_status_msg(status);
-            free(status_msg);
-            status_msg = xasprintf("%d crashes: pid %lu died, %s",
-                                   ++crashes,
-                                   (unsigned long int) daemon_pid, s);
-            free(s);
-
             if (should_restart(status)) {
+                free(status_msg);
+                status_msg = xasprintf("%d crashes: pid %lu died, %s",
+                                       ++crashes,
+                                       (unsigned long int) daemon_pid, s);
+                free(s);
+
                 if (WCOREDUMP(status)) {
                     /* Disable further core dumps to save disk space. */
                     struct rlimit r;
@@ -407,7 +407,9 @@ monitor_daemon(pid_t daemon_pid)
                     break;
                 }
             } else {
-                VLOG_INFO("%s, exiting", status_msg);
+                VLOG_INFO("pid %lu died, %s, exiting",
+                          (unsigned long int) daemon_pid, s);
+                free(s);
                 exit(0);
             }
         }
@@ -498,7 +500,7 @@ daemon_usage(void)
         "  --pidfile[=FILE]        create pidfile (default: %s/%s.pid)\n"
         "  --overwrite-pidfile     with --pidfile, start even if already "
                                    "running\n",
-        ovs_rundir, program_name);
+        ovs_rundir(), program_name);
 }
 
 /* Opens and reads a PID from 'pidfile'.  Returns the nonnegative PID if