httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@ai.mit.edu (Robert S. Thau)
Subject patch11.inc-cgi-pause
Date Sun, 27 Aug 1995 10:19:26 GMT
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 <!--#exec cmd--> 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 <!--#exec cmd=""--> 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;
      

Mime
View raw message