Commit 04f843cd authored by Geoff Simmons's avatar Geoff Simmons

Write stderr messages one line at a time to the Varnish log.

parent cac7d254
......@@ -2,8 +2,6 @@
varnishtest "vdp error handling"
shell "rm -f ${tmpdir}/foo"
server s1 {
rxreq
txresp -body {foo bar baz quux}
......@@ -14,7 +12,7 @@ varnish v1 -vcl+backend {
sub vcl_init {
new cat = pipe.vdp(path="${cat}");
cat.arg("${tmpdir}/foo");
cat.arg("-notalegaloption");
}
sub vcl_deliver {
......@@ -29,6 +27,6 @@ client c1 {
logexpect l1 -v v1 -g vxid -d 1 -q Error {
expect 0 * Begin {^req \d+ rxreq$}
expect * = Error {^vdfp_pipe: vdp cat: ${cat} stderr}
expect * = Error {^vdfp_pipe: vdp cat: ${cat} stderr: }
expect * = End
} -run
......@@ -437,10 +437,28 @@ vdp_bytes(struct req *req, enum vdp_action act, void **priv, const void *ptr,
}
continue;
}
// XXX write one line at a time
VSLb(req->vsl, SLT_Error, "vdfp_pipe: vdp %s: %s "
"stderr ...", obj->name, obj->path);
VSLb_bin(req->vsl, SLT_Error, nbytes, state->buf);
/* Log the stderr message one line at a time. */
for (char *errmsg = state->buf; nbytes > 0;) {
size_t linelen;
char *newline = memchr(errmsg, '\n', nbytes);
if (newline == NULL)
linelen = nbytes;
else
linelen = newline - errmsg;
assert(linelen <= (unsigned)nbytes);
if (linelen == 0) {
nbytes--;
errmsg++;
continue;
}
VSLb(req->vsl, SLT_Error,
"vdfp_pipe: vdp %s: %s stderr: %.*s",
obj->name, obj->path, (int)linelen,
errmsg);
nbytes -= (linelen + 1);
errmsg += (linelen + 1);
}
}
if (act == VDP_END) {
if (fds[STDIN_FILENO].fd != -1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment