Mailing List Archive

r2472 - trunk/varnish-cache/bin/varnishd
Author: phk
Date: 2008-02-15 11:36:21 +0100 (Fri, 15 Feb 2008)
New Revision: 2472

Modified:
trunk/varnish-cache/bin/varnishd/mgt_child.c
Log:
Log everything we see on the childs stdout/stderr to syslog.


Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-02-15 10:34:42 UTC (rev 2471)
+++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-02-15 10:36:21 UTC (rev 2472)
@@ -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 @@
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 @@
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);
r2472 - trunk/varnish-cache/bin/varnishd [ In reply to ]
In message <20080215103621.577A61EC2A4 at projects.linpro.no>, phk at projects.linpro
.no writes:

>New Revision: 2472
>
>Log everything we see on the childs stdout/stderr to syslog.

I should have done this a long time ago, but I guess I was too
optimistic about the lack of need for it.

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.