diff options
Diffstat (limited to 'modules/generators/mod_cgid.c')
-rw-r--r-- | modules/generators/mod_cgid.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c index b827ed6..4bab59f 100644 --- a/modules/generators/mod_cgid.c +++ b/modules/generators/mod_cgid.c @@ -608,6 +608,7 @@ static int cgid_server(void *data) apr_status_t rv; apr_pool_create(&ptrans, pcgi); + apr_pool_tag(ptrans, "cgid_ptrans"); apr_signal(SIGCHLD, SIG_IGN); apr_signal(SIGHUP, daemon_signal_handler); @@ -626,6 +627,9 @@ static int cgid_server(void *data) return errno; } + apr_pool_cleanup_register(pcgi, (void *)((long)sd), + close_unix_socket, close_unix_socket); + omask = umask(0077); /* so that only Apache can use socket */ rc = bind(sd, (struct sockaddr *)server_addr, server_addr_len); umask(omask); /* can't fail, so can't clobber errno */ @@ -660,9 +664,6 @@ static int cgid_server(void *data) } } - apr_pool_cleanup_register(pcgi, (void *)((long)sd), - close_unix_socket, close_unix_socket); - /* if running as root, switch to configured user/group */ if ((rc = ap_run_drop_privileges(pcgi, ap_server_conf)) != 0) { return rc; @@ -879,6 +880,7 @@ static int cgid_start(apr_pool_t *p, server_rec *main_server, else if (daemon_pid == 0) { if (pcgi == NULL) { apr_pool_create(&pcgi, p); + apr_pool_tag(pcgi, "cgid_pcgi"); } exit(cgid_server(main_server) > 0 ? DAEMON_STARTUP_ERROR : -1); } @@ -1275,19 +1277,15 @@ static void discard_script_output(apr_bucket_brigade *bb) apr_bucket *e; const char *buf; apr_size_t len; - apr_status_t rv; for (e = APR_BRIGADE_FIRST(bb); - e != APR_BRIGADE_SENTINEL(bb); - e = APR_BUCKET_NEXT(e)) + e != APR_BRIGADE_SENTINEL(bb) && !APR_BUCKET_IS_EOS(e); + e = APR_BRIGADE_FIRST(bb)) { - if (APR_BUCKET_IS_EOS(e)) { - break; - } - rv = apr_bucket_read(e, &buf, &len, APR_BLOCK_READ); - if (rv != APR_SUCCESS) { + if (apr_bucket_read(e, &buf, &len, APR_BLOCK_READ)) { break; } + apr_bucket_delete(e); } } @@ -1618,9 +1616,18 @@ static int cgid_handler(request_rec *r) b = apr_bucket_eos_create(c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, b); - if ((ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf, - APLOG_MODULE_INDEX))) - { + ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf, + APLOG_MODULE_INDEX); + + /* xCGI has its own body framing mechanism which we don't + * match against any provided Content-Length, so let the + * core determine C-L vs T-E based on what's actually sent. + */ + if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR)) + apr_table_unset(r->headers_out, "Content-Length"); + apr_table_unset(r->headers_out, "Transfer-Encoding"); + + if (ret != OK) { ret = log_script(r, conf, ret, dbuf, sbuf, bb, NULL); /* |