diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2023-04-27 00:43:50 -0400 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2023-05-03 23:11:35 -0400 |
commit | 07493ea5ff1fc8cbc8b4238b5e76dacfdc780bc8 (patch) | |
tree | ca4019714a4449e8c87f720a3b58e7591d2307ed | |
parent | cc3814db536cd3f6e3701d0949f1f29337fd8424 (diff) | |
download | lighttpd-git-07493ea5ff1fc8cbc8b4238b5e76dacfdc780bc8.tar.gz |
[mod_cgi] move fd count to cgi_create_env()
-rw-r--r-- | src/mod_cgi.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/mod_cgi.c b/src/mod_cgi.c index f47448cc..ec9ffeda 100644 --- a/src/mod_cgi.c +++ b/src/mod_cgi.c @@ -757,13 +757,7 @@ static int cgi_write_request(handler_ctx *hctx, int fd) { if (cq->bytes_out == (off_t)r->reqbody_length && !hctx->conf.upgrade) { /* sent all request body input */ /* close connection to the cgi-script */ - if (-1 == hctx->fdtocgi) { /*(received request body sent in initial send to pipe buffer)*/ - --r->con->srv->cur_fds; - if (fdio_close_pipe(fd)) - log_perror(r->conf.errh, __FILE__, __LINE__, "cgi stdin close %d failed", fd); - } else { - cgi_connection_close_fdtocgi(hctx); /*(closes only hctx->fdtocgi)*/ - } + cgi_connection_close_fdtocgi(hctx); /*(closes only hctx->fdtocgi)*/ } else { off_t cqlen = chunkqueue_length(cq); if (cq->bytes_in != r->reqbody_length && cqlen < 65536 - 16384) { @@ -1049,8 +1043,11 @@ static int cgi_create_env(request_st * const r, plugin_data * const p, handler_c } else if (0 == fdevent_fcntl_set_nb(to_cgi_fds[1]) && 0 == cgi_write_request(hctx, to_cgi_fds[1])) { + if (-1 == hctx->fdtocgi) /*(body fully sent in initial write)*/ + fdio_close_pipe(to_cgi_fds[1]); + else /*(fdevent_register() was called on fd opened further above)*/ + ++r->con->srv->cur_fds; fdio_close_pipe(to_cgi_fds[0]); - ++r->con->srv->cur_fds; } else { fdio_close_pipe(to_cgi_fds[0]); |