diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2016-04-25 02:45:49 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2016-04-25 02:45:49 +0100 |
commit | 1d61e3a5e807c5356bfa4158c248013e3be788d4 (patch) | |
tree | e11751337549787475328585b09cdcf6acfb75f0 /cprogs | |
parent | 84351242462d8d501402ee63536b4f56be03e1c7 (diff) |
cgi-fcgi-interp: Fix logger buffer-handling bugs.
Diffstat (limited to 'cprogs')
-rw-r--r-- | cprogs/cgi-fcgi-interp.c | 10 | ||||
-rwxr-xr-x | cprogs/cgi-fcgi-test | 6 |
2 files changed, 13 insertions, 3 deletions
diff --git a/cprogs/cgi-fcgi-interp.c b/cprogs/cgi-fcgi-interp.c index 2c157d2..7a5a5db 100644 --- a/cprogs/cgi-fcgi-interp.c +++ b/cprogs/cgi-fcgi-interp.c @@ -789,12 +789,19 @@ static void errpipe_readable(void) { static char buf[1024]; static int pending; + /* %: does not contain newlines + * _: empty (garbage) + */ + + /* %%%%%%%%%%%__________________ */ + /* ^ pending */ + for (;;) { int avail = sizeof(buf) - pending; ssize_t got = read(errpipe, buf+pending, avail); if (got==-1) { if (errno==EINTR) continue; - else if (errno==EWOULDBLOCK || errno==EAGAIN) /*ok*/; + else if (errno==EWOULDBLOCK || errno==EAGAIN) return; else diee("(stage2) errpipe read"); got = 0; } else if (got==0) { @@ -819,6 +826,7 @@ static void errpipe_readable(void) { } syslog(LOG_ERR,"stderr: %.*s", printupto-eaten, buf+eaten); eaten += eat; + scanned = eaten; } pending -= eaten; memmove(buf, buf+eaten, pending); diff --git a/cprogs/cgi-fcgi-test b/cprogs/cgi-fcgi-test index 4c8d7b7..3d5f0ed 100755 --- a/cprogs/cgi-fcgi-test +++ b/cprogs/cgi-fcgi-test @@ -23,13 +23,15 @@ print STDERR "[$$ stderr starting]\n"; print REALSTDERR "[$$ real-stderr starting]\n"; while ($request->Accept >= 0) { + my $ua = $ENV{HTTP_USER_AGENT} // '<none>'; print <<END; Content-Type; text/plain success count=$count +$ua END - print STDERR "[$$ stderr] serviced $count.\n"; - print REALSTDERR "[$$ real-stderr] serviced $count.\n"; + print STDERR "[$$ stderr] serviced $count ($ua).\n"; + print REALSTDERR "[$$ real-stderr] serviced $count ($ua).\n"; $count++; } |