diff options
author | Bret Lambert <blambert@cvs.openbsd.org> | 2013-09-11 09:31:23 +0000 |
---|---|---|
committer | Bret Lambert <blambert@cvs.openbsd.org> | 2013-09-11 09:31:23 +0000 |
commit | c1667c0f4d5c1117cad4c8c8c01451b330fa8c0e (patch) | |
tree | 443d13cc88581e43edbeca7a469a83e4e8aff8cc /usr.sbin/slowcgi/slowcgi.c | |
parent | b540fe3d3efd8801bae8e94e4da297fcec071c26 (diff) |
Sprinkle some comments which clarify the protocol/process flow.
ok florian@
Diffstat (limited to 'usr.sbin/slowcgi/slowcgi.c')
-rw-r--r-- | usr.sbin/slowcgi/slowcgi.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/usr.sbin/slowcgi/slowcgi.c b/usr.sbin/slowcgi/slowcgi.c index 963c32b6661..7ebe6415649 100644 --- a/usr.sbin/slowcgi/slowcgi.c +++ b/usr.sbin/slowcgi/slowcgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slowcgi.c,v 1.9 2013/09/06 12:17:28 blambert Exp $ */ +/* $OpenBSD: slowcgi.c,v 1.10 2013/09/11 09:31:22 blambert Exp $ */ /* * Copyright (c) 2013 David Gwynne <dlg@openbsd.org> * Copyright (c) 2013 Florian Obser <florian@openbsd.org> @@ -542,6 +542,12 @@ slowcgi_request(int fd, short events, void *arg) c->buf_len += n; + /* + * Parse the records as they are received. Per the FastCGI + * specification, the server need only receive the FastCGI + * parameter records in full; it is free to begin execution + * at that point, which is what happens here. + */ do { parsed = parse_request(c->buf + c->buf_pos, c->buf_len, c); c->buf_pos += parsed; @@ -600,10 +606,15 @@ parse_params(uint8_t *buf, uint16_t n, struct client *c, uint16_t id) name_len = val_len = 0; + /* + * If this is the last FastCGI parameter record, + * begin execution of the CGI script. + */ if (n == 0) { exec_cgi(c); return; } + while (n > 0) { if (buf[0] >> 7 == 0) { name_len = buf[0]; @@ -739,6 +750,12 @@ parse_request(uint8_t *buf, size_t n, struct client *c) + h->padding_len); } +/* + * Fork a new CGI process to handle the request, translating + * between FastCGI parameter records and CGI's environment variables, + * as well as between the CGI process' stdin/stdout and the + * corresponding FastCGI records. + */ void exec_cgi(struct client *c) { |