Package: fcgiwrap
Version: 1.1.0-5
Tags: patch

Some cgi scripts need to be able to send small ammounts of output incrementally 
to clients. An example that I ran into recently was git-http-backend . Without 
the ability to send progress information to clients clones of large repos will 
result in gateway timeouts.

Unfortunately buffering in the fcgi interface prevents this. I found a patch on 
github to add an option to disable buffering and backported it to the Debian 
jessie package. I would appreciate if it was added to the Debian package so I 
don't have to maintain it locally.

Debdiff attatched, no intent to NMU.


diff -Nru fcgiwrap-1.1.0/debian/changelog fcgiwrap-1.1.0/debian/changelog
--- fcgiwrap-1.1.0/debian/changelog     2015-04-03 08:22:41.000000000 +0000
+++ fcgiwrap-1.1.0/debian/changelog     2017-05-27 12:07:04.000000000 +0000
@@ -1,3 +1,9 @@
+fcgiwrap (1.1.0-5+unbuffered) UNRELEASED; urgency=medium
+
+  * Add patch to support unbuffered operation.
+
+ -- root <r...@bytemark2017.raspbian.org>  Sat, 27 May 2017 12:06:27 +0000
+
 fcgiwrap (1.1.0-5) unstable; urgency=medium
 
   * Add a prerm script that forcibly stops fcgiwrap.socket, to avoid
diff -Nru fcgiwrap-1.1.0/debian/patches/series 
fcgiwrap-1.1.0/debian/patches/series
--- fcgiwrap-1.1.0/debian/patches/series        2015-04-01 07:37:45.000000000 
+0000
+++ fcgiwrap-1.1.0/debian/patches/series        2017-05-27 12:05:32.000000000 
+0000
@@ -2,3 +2,4 @@
 fix_systemd.patch
 fix_mandir.patch
 systemd_socket_requires.patch
+support-unbuffered.patch
diff -Nru fcgiwrap-1.1.0/debian/patches/support-unbuffered.patch 
fcgiwrap-1.1.0/debian/patches/support-unbuffered.patch
--- fcgiwrap-1.1.0/debian/patches/support-unbuffered.patch      1970-01-01 
00:00:00.000000000 +0000
+++ fcgiwrap-1.1.0/debian/patches/support-unbuffered.patch      2017-05-27 
12:28:33.000000000 +0000
@@ -0,0 +1,45 @@
+Backported to Debian package by Peter Michael Green.
+
+commit 84c8b63fef6e400894ccc3c67f350ef868ab2e14
+Author: Richard Stanway <r.stan...@gmail.com>
+Date:   Thu Mar 24 21:34:17 2016 -0500
+
+    Add support for unbuffered output
+
+Index: fcgiwrap-1.1.0/fcgiwrap.c
+===================================================================
+--- fcgiwrap-1.1.0.orig/fcgiwrap.c
++++ fcgiwrap-1.1.0/fcgiwrap.c
+@@ -191,6 +191,7 @@ struct fcgi_context {
+       int fd_stderr;
+       unsigned int reply_state;
+       pid_t cgi_pid;
++      int unbuffered;
+ };
+ 
+ static void fcgi_finish(struct fcgi_context *fc, const char* msg)
+@@ -256,6 +257,10 @@ out_of_loop:
+                               return "writing CGI reply";
+                       }
+               }
++
++              if (fc->unbuffered) {
++                      FCGI_fflush(ffp);
++              }
+       } else {
+               if (nread < 0) {
+                       return "reading CGI reply";
+@@ -583,6 +588,13 @@ static void handle_fcgi_request(void)
+                       fc.reply_state = REPLY_STATE_INIT;
+                       fc.cgi_pid = pid;
+ 
++                      char *p = getenv("NO_BUFFERING");
++                      if (p) {
++                              fc.unbuffered = 1;
++                      } else {
++                              fc.unbuffered = 0;
++                      }
++
+                       fcgi_pass(&fc);
+       }
+       return;

Reply via email to