Code

Updated to upstream version 1.4.8.
[pkg-rrdtool.git] / src / rrd_daemon.c
index 17153ce98be3309f985b885b486e3a0fc7b5fd6d..ed7bb4de9f9f59ae52b49245f12ae6056026ebd3 100644 (file)
 #include <tcpd.h>
 #endif /* HAVE_LIBWRAP */
 
-#include <glib-2.0/glib.h>
+#include <glib.h>
 /* }}} */
 
 #define RRDD_LOG(severity, ...) \
@@ -292,7 +292,9 @@ static int handle_request_help (HANDLER_PROTO);
 static void sig_common (const char *sig) /* {{{ */
 {
   RRDD_LOG(LOG_NOTICE, "caught SIG%s", sig);
-  state = FLUSHING;
+  if (state == RUNNING) {
+      state = FLUSHING;
+  }
   pthread_cond_broadcast(&flush_cond);
   pthread_cond_broadcast(&queue_cond);
 } /* }}} void sig_common */
@@ -3091,7 +3093,17 @@ static int read_options (int argc, char **argv) /* {{{ */
       {
         char journal_dir_actual[PATH_MAX];
         const char *dir;
-        dir = journal_dir = strdup(realpath((const char *)optarg, journal_dir_actual));
+        if (realpath((const char *)optarg, journal_dir_actual) == NULL)
+        {
+          fprintf(stderr, "Failed to canonicalize the journal directory '%s': %s\n",
+              optarg, rrd_strerror(errno));
+          return 7;
+        }
+        dir = journal_dir = strdup(journal_dir_actual);
+        if (dir == NULL) {
+          fprintf (stderr, "read_options: strdup failed.\n");
+          return (3);
+        }
 
         status = rrd_mkdir_p(dir, 0777);
         if (status != 0)