* updated yet more dir-less .cache DEPs
[t2sde.git] / package / network / fcgiwrap / no-buffering.patch.musl
bloba60beea57a38bda042505280e72fccea193c4246
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/fcgiwrap/no-buffering.patch.musl
3 # Copyright (C) 2024 The T2 SDE Project
4
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7
8 # This patch file is dual-licensed. It is available under the license the
9 # patched project is licensed under, as long as it is an OpenSource license
10 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
11 # of the GNU General Public License version 2 as used by the T2 SDE.
12 # --- T2-COPYRIGHT-NOTE-END ---
14 From eb54c65446693366aedfe72f002c6bb4e1a5d748 Mon Sep 17 00:00:00 2001
15 From: Richard Stanway <r.stanway@gmail.com>
16 Date: Thu, 24 Mar 2016 21:34:17 -0500
17 Subject: [PATCH] Add environment variable NO_BUFFERING to disable output
18  buffering
20 Fixes #36
21 ---
22  fcgiwrap.8 | 4 ++++
23  fcgiwrap.c | 6 ++++++
24  2 files changed, 10 insertions(+)
26 diff --git a/fcgiwrap.8 b/fcgiwrap.8
27 index bf02c26..892b594 100644
28 --- a/fcgiwrap.8
29 +++ b/fcgiwrap.8
30 @@ -65,6 +65,10 @@
31  SCRIPT_FILENAME
32  .RS
33  complete path to CGI script. When set, overrides DOCUMENT_ROOT and SCRIPT_NAME
34 +.RE
35 +NO_BUFFERING
36 +.RS
37 +When set (e.g., to ""), disables output buffering.
39  .SH EXAMPLE
40  The fastest way to see \fBfcgiwrap\fP do something is to launch it at the command line
41 diff --git a/fcgiwrap.c b/fcgiwrap.c
42 index b44d8aa..42e3ec9 100644
43 --- a/fcgiwrap.c
44 +++ b/fcgiwrap.c
45 @@ -191,6 +191,7 @@ struct fcgi_context {
46         int fd_stderr;
47         unsigned int reply_state;
48         pid_t cgi_pid;
49 +       int unbuffered;
50  };
52  static void fcgi_finish(struct fcgi_context *fc, const char* msg)
53 @@ -256,6 +257,10 @@ static const char * fcgi_pass_fd(struct fcgi_context *fc, int *fdp, FCGI_FILE *f
54                                 return "writing CGI reply";
55                         }
56                 }
58 +               if (fc->unbuffered && FCGI_fflush(ffp)) {
59 +                       return "flushing CGI reply";
60 +               }
61         } else {
62                 if (nread < 0) {
63                         return "reading CGI reply";
64 @@ -590,6 +595,7 @@ static void handle_fcgi_request(void)
65                         fc.fd_stderr = pipe_err[0];
66                         fc.reply_state = REPLY_STATE_INIT;
67                         fc.cgi_pid = pid;
68 +                       fc.unbuffered = !!getenv("NO_BUFFERING");
70                         fcgi_pass(&fc);
71         }