You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Igor Plotnikov <ig...@writeme.com> on 1999/02/05 20:33:09 UTC

os-windows/3846: CGI don't get terminated if browser aborts connection

>Number:         3846
>Category:       os-windows
>Synopsis:       CGI don't get terminated if browser aborts connection
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Fri Feb  5 11:40:01 PST 1999
>Last-Modified:
>Originator:     igor_irina@writeme.com
>Organization:
apache
>Release:        1.3.4
>Environment:
Win32, v.1.3.4 compiled with VisualStudio 6.0
>Description:
1) browser places request to a CGI that has extended time span
2) browser terminates connection by pressing Stop or hitting Escape
3) the CGI doen's get killed by Apache, and either eventually expires, or
   turns into a zombie
>How-To-Repeat:

>Fix:
According to my observations there are several issues here that contribute 
to the problem, some of them related to mod_cgi, and some of them
more general.

My understanding that both Windows and Unix versions simularily detect that 
connection is dropped and set r->connection->aborted to 1
1) Then Windows version gets stuck in mod_cgi.c in this place:
  while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
      continue;
  }
Basically, it attempts to read from script's stderr, and doesn't return from
the blocking ReadFile call. Unix version doesn't have this problem. Don't
know why, perhaps because it relies on SIGPIPE which doesn't work on Win32.
I circumvented this problem by using
  if(!r->connection->aborted) {
	  while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
	      continue;
	  }
  }
I'm not really suggesting to use this, but it allowed me to get to other issues.

Now, Unix version kills CGIs off in the child_main in http_main.c through
calling 
ap_clear_pool(ptrans);
>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, ]
[you need to include <ap...@Apache.Org> in the Cc line ]
[and leave the subject line UNCHANGED.  This is not done]
[automatically because of the potential for mail loops. ]
[If you do not include this Cc, your reply may be ig-   ]
[nored unless you are responding to an explicit request ]
[from a developer.                                      ]
[Reply only with text; DO NOT SEND ATTACHMENTS!         ]