Return-Path: owner-new-httpd Received: by taz.hyperreal.com (8.6.12/8.6.5) id HAA12063; Sun, 27 Aug 1995 07:19:34 -0700 Received: from life.ai.mit.edu by taz.hyperreal.com (8.6.12/8.6.5) with SMTP id HAA12058; Sun, 27 Aug 1995 07:19:32 -0700 Received: from volterra (volterra.ai.mit.edu) by life.ai.mit.edu (4.1/AI-4.10) for new-httpd@mail.apache.org id AA25032; Sun, 27 Aug 95 10:19:28 EDT From: rst@ai.mit.edu (Robert S. Thau) Received: by volterra (4.1/AI-4.10) id AA12088; Sun, 27 Aug 95 10:19:26 EDT Date: Sun, 27 Aug 95 10:19:26 EDT Message-Id: <9508271419.AA12088@volterra> To: new-httpd@mail.apache.org Subject: patch11.inc-cgi-pause Sender: owner-new-httpd@apache.org Precedence: bulk Reply-To: new-httpd@apache.org This eliminates the "pause after including CGI script" behavior observed with certain scripts on certain systems, for which you get "SIGTERM/pause/ kill" routine before the script has a chance to die on its own. The same problem exists for children, and is fixed for them as well. It works by not even trying to mop up these subprocesses until we are wrapping up the connection, after we have sent the entire document --- this is done by spawning the process off the per- connection resource pool, rather than the per-request resource pool. I also added code to close the FILE *'s associated with communication with CGI scripts, since an include page which otherwise includes a *lot* of CGI children might otherwise run out of file descriptors. (These were formerly closed when the per-process resource pool was cleaned up; the descriptor was already being closed for children). NB to reliably duplicate this bug, I had to write a CGI script that closes stdout and then sleeps for a second, to guarantee inopportune timing. diff -c ./mod_cgi.c ../mod_cgi.c *** ./mod_cgi.c Sun Aug 27 09:16:45 1995 --- ../mod_cgi.c Sun Aug 27 09:35:01 1995 *************** *** 264,270 **** add_common_vars (r); cld.argv0 = argv0; cld.r = r; cld.nph = nph; ! if (!spawn_child (r->pool, cgi_child, (void *)&cld, nph ? just_wait : kill_after_timeout, &script_out, nph ? NULL : &script_in)) { log_reason ("couldn't spawn child process", r->filename, r); --- 264,270 ---- add_common_vars (r); cld.argv0 = argv0; cld.r = r; cld.nph = nph; ! if (!spawn_child (r->connection->pool, cgi_child, (void *)&cld, nph ? just_wait : kill_after_timeout, &script_out, nph ? NULL : &script_in)) { log_reason ("couldn't spawn child process", r->filename, r); *************** *** 304,309 **** --- 304,311 ---- kill_timeout (r); } + pfclose (r->connection->pool, script_out); + /* Handle script return... */ if (script_in && !nph) { *************** *** 337,342 **** --- 339,345 ---- send_http_header(r); if(!r->header_only) send_fd (script_in, r); kill_timeout (r); + pfclose (r->connection->pool, script_in); } return OK; /* NOT r->status, even if it has changed. */ diff -c ./mod_include.c ../mod_include.c *** ./mod_include.c Sun Aug 27 09:16:45 1995 --- ../mod_include.c Sun Aug 27 09:36:12 1995 *************** *** 470,476 **** arg.r = r; arg.s = s; ! if (!spawn_child (r->pool, include_cmd_child, &arg, kill_after_timeout, NULL, &f)) return -1; --- 470,476 ---- arg.r = r; arg.s = s; ! if (!spawn_child (r->connection->pool, include_cmd_child, &arg, kill_after_timeout, NULL, &f)) return -1;