X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Frrd_daemon.c;h=5163f34bc9ed924e9e0a76f480ba9cd3da0651cb;hb=692408d69df63d4aef3f9d0542edeef8c64a9eaa;hp=ead969b4a7a5e8984512e79a7a691c5e41e8b4a4;hpb=fa8321e707399f0128908cba6e607c617580088d;p=rrdtool.git diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index ead969b..5163f34 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -1339,14 +1339,14 @@ static int handle_request (int fd, socket_privilege privilege, /* {{{ */ if (strcasecmp (command, "update") == 0) { - /* don't re-write updates in replay mode */ - if (fd >= 0) - journal_write(command, buffer_ptr); - status = has_privilege(privilege, PRIV_HIGH, fd); if (status <= 0) return status; + /* don't re-write updates in replay mode */ + if (fd >= 0) + journal_write(command, buffer_ptr); + return (handle_request_update (fd, buffer_ptr, buffer_size)); } else if (strcasecmp (command, "wrote") == 0 && fd < 0) @@ -1999,6 +1999,7 @@ static int daemonize (void) /* {{{ */ { int status; int fd; + char *base_dir; fd = open_pidfile(); if (fd < 0) return fd; @@ -2006,7 +2007,6 @@ static int daemonize (void) /* {{{ */ if (!stay_foreground) { pid_t child; - char *base_dir; child = fork (); if (child < 0) @@ -2019,17 +2019,6 @@ static int daemonize (void) /* {{{ */ return (1); } - /* Change into the /tmp directory. */ - base_dir = (config_base_dir != NULL) - ? config_base_dir - : "/tmp"; - status = chdir (base_dir); - if (status != 0) - { - fprintf (stderr, "daemonize: chdir (%s) failed.\n", base_dir); - return (-1); - } - /* Become session leader */ setsid (); @@ -2043,6 +2032,17 @@ static int daemonize (void) /* {{{ */ dup (0); } /* if (!stay_foreground) */ + /* Change into the /tmp directory. */ + base_dir = (config_base_dir != NULL) + ? config_base_dir + : "/tmp"; + status = chdir (base_dir); + if (status != 0) + { + fprintf (stderr, "daemonize: chdir (%s) failed.\n", base_dir); + return (-1); + } + install_signal_handlers(); openlog ("rrdcached", LOG_PID, LOG_DAEMON);