summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Nosek <root@localdomain.pl>2008-05-05 21:44:04 +0200
committerGrzegorz Nosek <root@localdomain.pl>2008-05-05 21:44:04 +0200
commitad0e571db068aedf4dda7e08d5d85a06a3b95192 (patch)
tree026b225ae091e227ecd21238cb228442c3fb34c3
parent978f549e1c8e96a8fa0023102e4844bad1278390 (diff)
downloadfcgiwrap-ad0e571db068aedf4dda7e08d5d85a06a3b95192.tar.xz
fcgiwrap-ad0e571db068aedf4dda7e08d5d85a06a3b95192.zip
Split out passing the request to a separate function
-rw-r--r--fcgiwrap.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/fcgiwrap.c b/fcgiwrap.c
index c4369d5..c1a19ab 100644
--- a/fcgiwrap.c
+++ b/fcgiwrap.c
@@ -11,6 +11,7 @@
#include <string.h>
#include <sys/stat.h>
#include <limits.h>
+#include <stdbool.h>
extern char **environ;
static char * const * inherited_environ;
@@ -233,25 +234,35 @@ static const char * fcgi_pass_raw_fd(int *fdp, int fd_out, char *buf, size_t buf
return NULL;
}
-static void fcgi_pass(struct fcgi_context *fc)
+static bool fcgi_pass_request(struct fcgi_context *fc)
{
char buf[FCGI_BUF_SIZE];
ssize_t nread;
- fd_set rset;
- int maxfd = 1 + max_va(fc->fd_stdout, fc->fd_stderr, MAX_VA_SENTINEL);
- int nready;
- const char *err;
/* eat the whole request and pass it to CGI */
while ((nread = FCGI_fread(buf, 1, sizeof(buf), FCGI_stdin)) > 0) {
if (write_all(fc->fd_stdin, buf, nread) <= 0) {
fcgi_finish(fc, "reading the request");
- return;
+ return false;
}
}
close(fc->fd_stdin);
fc->fd_stdin = -1;
+ return true;
+}
+
+static void fcgi_pass(struct fcgi_context *fc)
+{
+ char buf[FCGI_BUF_SIZE];
+ fd_set rset;
+ int maxfd = 1 + max_va(fc->fd_stdout, fc->fd_stderr, MAX_VA_SENTINEL);
+ int nready;
+ const char *err;
+
+ if (!fcgi_pass_request(fc))
+ return;
+
/* now pass CGI reply back */
while (fc->fd_stdout >= 0 && fc->fd_stderr >= 0) {
FD_ZERO(&rset);