From f740468deb2adc744415c81c6337e29e4306883a Mon Sep 17 00:00:00 2001 From: Ryan Bloom Date: Wed, 21 Feb 2001 19:07:21 +0000 Subject: [PATCH] Close the accepted socket before creating the CGI process in mod_cgid. This is safe, because we have already dup'ed the socket for the CGI process itself. This change allows CGI processes to fork long-lived child processes without affecting how quickly the response gets back to the broswer. PR: 7273 Submitted by: Taketo Kabe Reviewed by: Ryan Bloom git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88264 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 6 ++++++ modules/generators/mod_cgid.c | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 5cc1e4ea5d..442a67045b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,11 @@ Changes with Apache 2.0.12-dev + *) Close one copy of the CGI's stdout before creating the new process. + The CGI will still have stdout, because we have already dup'ed it. + This keeps Apache from waiting forever to send the results of a CGI + process that has forked a long-lived child process. + [Taketo Kabe ] + *) Remove the rest of the pthreads functions from the threaded MPM. This requires the APR support for a signal thread that was just added. [Ryan Bloom] diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c index dc7b647a47..a7e1618f85 100644 --- a/modules/generators/mod_cgid.c +++ b/modules/generators/mod_cgid.c @@ -549,11 +549,20 @@ static int cgid_server(void *data) } else { argv = (const char * const *)create_argv(r->pool, NULL, NULL, NULL, argv0, r->args); + + /* We want to sd2 close for new CGI process too. + * If it's remained open it'll make ap_pass_brigade() block + * waiting for EOF if CGI forked something running long. + * close(sd2) here should be okay, as CGI channel + * is already dup()ed by apr_procattr_child_{in,out}_set() + * above. + */ + close(sd2); + rc = ap_os_create_privileged_process(r, procnew, argv0, argv, (const char * const *)env, procattr, p); - close(sd2); if (rc != APR_SUCCESS) { /* Bad things happened. Everyone should have cleaned up. */ ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, -- 2.50.1