]> err.no Git - varnish/commitdiff
Log everything we see on the childs stdout/stderr to syslog.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 15 Feb 2008 10:36:21 +0000 (10:36 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 15 Feb 2008 10:36:21 +0000 (10:36 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2472 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/mgt_child.c

index 1c2f437581cd6fb3fae12e045f949ee9441a2157..619ae81093b535dbfd4ad11395b3d087f42b6a04 100644 (file)
@@ -39,6 +39,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <signal.h>
+#include <syslog.h>
 #include <errno.h>
 #include <poll.h>
 #include <sys/types.h>
@@ -54,6 +55,7 @@
 #include "cli_priv.h"
 #include "mgt_cli.h"
 #include "mgt_event.h"
+#include "vlu.h"
 #include "vss.h"
 
 pid_t          mgt_pid;
@@ -79,28 +81,33 @@ static const char *ch_state[] = {
 struct evbase          *mgt_evb;
 static struct ev       *ev_poker;
 static struct ev       *ev_listen;
+static struct vlu      *vlu;
+
+/*--------------------------------------------------------------------*/
+
+static int
+child_line(void *priv, const char *p)
+{
+       (void)priv;
+
+       fprintf(stderr, "Child said (%d, %d): <<%s>>\n",
+           child_state, child_pid, p);
+       syslog(LOG_NOTICE, "Child (%d) said <<%s>>", child_pid, p);
+       return (0);
+}
 
 /*--------------------------------------------------------------------*/
 
 static int
 child_listener(const struct ev *e, int what)
 {
-       int i;
-       char buf[BUFSIZ];
 
        (void)e;
        if ((what & ~EV_RD)) {
                ev_listen = NULL;
                return (1);
        }
-       i = read(child_fds[0], buf, sizeof buf - 1);
-       if (i <= 0) {
-               ev_listen = NULL;
-               return (1);
-       }
-       buf[i] = '\0';
-       fprintf(stderr, "Child said (%d, %d): <<%s>>\n",
-           child_state, child_pid, buf);
+       VLU_Fd(child_fds[0], vlu);
        return (0);
 }
 
@@ -222,6 +229,9 @@ start_child(void)
        AZ(close(child_fds[1]));
        child_fds[1] = -1;
 
+       vlu = VLU_New(NULL, child_line);
+       AN(vlu);
+
        AZ(ev_listen);
        e = ev_new();
        XXXAN(e);