mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-04-19 05:36:38 +02:00
58 lines
1.5 KiB
Diff
58 lines
1.5 KiB
Diff
From eb54c65446693366aedfe72f002c6bb4e1a5d748 Mon Sep 17 00:00:00 2001
|
|
From: Richard Stanway <r.stanway@gmail.com>
|
|
Date: Thu, 24 Mar 2016 21:34:17 -0500
|
|
Subject: [PATCH] Add environment variable NO_BUFFERING to disable output
|
|
buffering
|
|
|
|
Fixes #36
|
|
---
|
|
fcgiwrap.8 | 4 ++++
|
|
fcgiwrap.c | 6 ++++++
|
|
2 files changed, 10 insertions(+)
|
|
|
|
diff --git a/fcgiwrap.8 b/fcgiwrap.8
|
|
index bf02c26..892b594 100644
|
|
--- a/fcgiwrap.8
|
|
+++ b/fcgiwrap.8
|
|
@@ -65,6 +65,10 @@
|
|
SCRIPT_FILENAME
|
|
.RS
|
|
complete path to CGI script. When set, overrides DOCUMENT_ROOT and SCRIPT_NAME
|
|
+.RE
|
|
+NO_BUFFERING
|
|
+.RS
|
|
+When set (e.g., to ""), disables output buffering.
|
|
|
|
.SH EXAMPLE
|
|
The fastest way to see \fBfcgiwrap\fP do something is to launch it at the command line
|
|
diff --git a/fcgiwrap.c b/fcgiwrap.c
|
|
index b44d8aa..42e3ec9 100644
|
|
--- a/fcgiwrap.c
|
|
+++ b/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 @@ static const char * fcgi_pass_fd(struct fcgi_context *fc, int *fdp, FCGI_FILE *f
|
|
return "writing CGI reply";
|
|
}
|
|
}
|
|
+
|
|
+ if (fc->unbuffered && FCGI_fflush(ffp)) {
|
|
+ return "flushing CGI reply";
|
|
+ }
|
|
} else {
|
|
if (nread < 0) {
|
|
return "reading CGI reply";
|
|
@@ -590,6 +595,7 @@ static void handle_fcgi_request(void)
|
|
fc.fd_stderr = pipe_err[0];
|
|
fc.reply_state = REPLY_STATE_INIT;
|
|
fc.cgi_pid = pid;
|
|
+ fc.unbuffered = !!getenv("NO_BUFFERING");
|
|
|
|
fcgi_pass(&fc);
|
|
}
|