chiark / gitweb /
cgi-fcgi-interp: Fix logger buffer-handling bugs.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 25 Apr 2016 01:45:49 +0000 (02:45 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 25 Apr 2016 01:45:49 +0000 (02:45 +0100)
cprogs/cgi-fcgi-interp.c
cprogs/cgi-fcgi-test
debian/changelog

index 2c157d218033a372c6e53c144cb091e29952ed18..7a5a5db6a3a6c3eb17d37749b1c2b65de63a06a0 100644 (file)
@@ -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);
index 4c8d7b79c34f4da321683a6c5db18dec2c42330f..3d5f0ed2a7016d83517697092738e270f8c6cf81 100755 (executable)
@@ -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++;
 }
index eded82e46fa733af76a7669353c0d266262fb599..9a02fbfb9190d27f73ca4ee883d013e7672282f8 100644 (file)
@@ -1,3 +1,9 @@
+chiark-utils (4.5.0~iwj3) unstable; urgency=medium
+
+  * cgi-fcgi-interp: Fix logger buffer-handling bugs.
+
+ -- Ian Jackson <ijackson@chiark.greenend.org.uk>  Mon, 25 Apr 2016 02:45:44 +0100
+
 chiark-utils (4.5.0~iwj2) UNRELEASED; urgency=medium
 
   * cgi-fcgi-interp: mkdir ~/.cgi-fcgi-interp if necessary.