From: Joe Orton Date: Wed, 5 May 2004 14:52:44 +0000 (+0000) Subject: * modules/generators/mod_cgi.c (cgi_handler): Combine common code X-Git-Tag: pre_ajp_proxy~274 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=46fb957d019ebdb6dd4d1265860fe1c7c5d6fbc7;p=apache * modules/generators/mod_cgi.c (cgi_handler): Combine common code between nph and non-nph handling; use a CGI bucket for both cases if APR_FILES_AS_SOCKETS. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@103621 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index cdebfcb9e9..8df27970f6 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -726,6 +726,7 @@ static int cgi_handler(request_rec *r) cgi_server_conf *conf; apr_status_t rv; cgi_exec_info_t e_info; + conn_rec *c = r->connection; if(strcmp(r->handler, CGI_MAGIC_TYPE) && strcmp(r->handler, "cgi-script")) return DECLINED; @@ -807,7 +808,7 @@ static int cgi_handler(request_rec *r) /* Transfer any put/post args, CERN style... * Note that we already ignore SIGPIPE in the core server. */ - bb = apr_brigade_create(r->pool, r->connection->bucket_alloc); + bb = apr_brigade_create(r->pool, c->bucket_alloc); seen_eos = 0; child_stopped_reading = 0; if (conf->logname) { @@ -883,24 +884,27 @@ static int cgi_handler(request_rec *r) apr_file_flush(script_out); apr_file_close(script_out); - /* Handle script return... */ - if (script_in && !nph) { - conn_rec *c = r->connection; - const char *location; - char sbuf[MAX_STRING_LEN]; - int ret; + AP_DEBUG_ASSERT(script_in != NULL); -#if APR_FILES_AS_SOCKETS - apr_file_pipe_timeout_set(script_in, 0); - apr_file_pipe_timeout_set(script_err, 0); + apr_brigade_cleanup(bb); - b = cgi_bucket_create(r, script_in, script_err, c->bucket_alloc); +#if APR_FILES_AS_SOCKETS + apr_file_pipe_timeout_set(script_in, 0); + apr_file_pipe_timeout_set(script_err, 0); + + b = cgi_bucket_create(r, script_in, script_err, c->bucket_alloc); #else - b = apr_bucket_pipe_create(script_in, c->bucket_alloc); + b = apr_bucket_pipe_create(script_in, c->bucket_alloc); #endif - APR_BRIGADE_INSERT_TAIL(bb, b); - b = apr_bucket_eos_create(c->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(bb, b); + APR_BRIGADE_INSERT_TAIL(bb, b); + b = apr_bucket_eos_create(c->bucket_alloc); + APR_BRIGADE_INSERT_TAIL(bb, b); + + /* Handle script return... */ + if (!nph) { + const char *location; + char sbuf[MAX_STRING_LEN]; + int ret; if ((ret = ap_scan_script_header_err_brigade(r, bb, sbuf))) { return log_script(r, conf, ret, dbuf, sbuf, bb, script_err); @@ -952,9 +956,7 @@ static int cgi_handler(request_rec *r) apr_file_close(script_err); } - - if (script_in && nph) { - conn_rec *c = r->connection; + else /* nph */ { struct ap_filter_t *cur; /* get rid of all filters up through protocol... since we @@ -968,11 +970,6 @@ static int cgi_handler(request_rec *r) } r->output_filters = r->proto_output_filters = cur; - bb = apr_brigade_create(r->pool, c->bucket_alloc); - b = apr_bucket_pipe_create(script_in, c->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(bb, b); - b = apr_bucket_eos_create(c->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(bb, b); ap_pass_brigade(r->output_filters, bb); }