]> granicus.if.org Git - apache/commitdiff
Call ap_pass_brigade() *before* soaking up stderr. The normal CGI
authorJeff Trawick <trawick@apache.org>
Sat, 26 Aug 2000 19:45:15 +0000 (19:45 +0000)
committerJeff Trawick <trawick@apache.org>
Sat, 26 Aug 2000 19:45:15 +0000 (19:45 +0000)
is going to write a bunch of stuff to stdout and nothing to stderr.
Reading stderr before processing the stdout pipe can cause deadlock if
the CGI fills the kernel buffer for stdout because the CGI will stall
writing to stdout while the httpd process will stall reading from the
CGI's stderr.

The NPH CGI behavior was unchanged.  If this is still a problem for NPH
CGIs, it was a problem before filtering too.

Also, get rid of a couple of unused variables in cgi_handler.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86150 13f79535-47bb-0310-9956-ffa450edef68

modules/generators/mod_cgi.c

index 183365f0ccf9b23e9ef88d362fe9590996548aa4..d929167181f47251d2fb3128b816b553c9dc4fcc 100644 (file)
@@ -311,8 +311,6 @@ static apr_status_t run_cgi_child(apr_file_t **script_out, apr_file_t **script_i
     apr_procattr_t *procattr;
     apr_proc_t *procnew = apr_pcalloc(p, sizeof(*procnew));
     apr_status_t rc = APR_SUCCESS;
-    apr_file_t *file = NULL;
-    apr_socket_t *sock = NULL;
 #if defined(RLIMIT_CPU)  || defined(RLIMIT_NPROC) || \
     defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS)
     core_dir_config *conf;
@@ -661,6 +659,7 @@ static int cgi_handler(request_rec *r)
             ap_brigade_append_buckets(bb, ap_bucket_create_pipe(script_in));
             ap_brigade_append_buckets(bb, ap_bucket_create_eos());
        }
+        ap_pass_brigade(r->filters, bb);
 
         log_script_err(r, script_err);
        apr_close(script_err);
@@ -670,9 +669,9 @@ static int cgi_handler(request_rec *r)
         bb = ap_brigade_create(r->pool);
         ap_brigade_append_buckets(bb, ap_bucket_create_pipe(script_in));
         ap_brigade_append_buckets(bb, ap_bucket_create_eos());
+        ap_pass_brigade(r->filters, bb);
     }
 
-    ap_pass_brigade(r->filters, bb);
     return OK;                 /* NOT r->status, even if it has changed. */
 }