Bug(?) with cgi scripts under CERN httpd

Bug(?) with cgi scripts under CERN httpd

Post by Chris Osbo » Sat, 17 Feb 1996 04:00:00



I'm having problems with cgi scripts not getting killed if httpd
is terminated.

Some of my scripts generate some very long documents, and users
get impatient and close the connection before the script has finished
writing its output. The httpd itself dies off, but the script and
all its children do not.

Is there something special I should be putting in the script to
catch a signal that httpd may be sending?

--
Chris Osborn, Network Administrator       Voice: 707 253 3130
Napa Valley College                         Fax: 707 253 3063
2277 Napa-Vallejo Hwy., Napa, CA, 94558

 
 
 

Bug(?) with cgi scripts under CERN httpd

Post by Daniel L. Bran » Sun, 18 Feb 1996 04:00:00


: I'm having problems with cgi scripts not getting killed if httpd
: is terminated.

: Some of my scripts generate some very long documents, and users
: get impatient and close the connection before the script has finished
: writing its output. The httpd itself dies off, but the script and
: all its children do not.

: Is there something special I should be putting in the script to
: catch a signal that httpd may be sending?

: --
: Chris Osborn, Network Administrator       Voice: 707 253 3130
: Napa Valley College                         Fax: 707 253 3063
: 2277 Napa-Vallejo Hwy., Napa, CA, 94558

I had the same problem with CERN 3.0 running on a Linux server. If you do
a search on the cgi newsgroup, you will discover that others have problems
also with the CERN httpd failing to terminate its children when the user
aborts the download.

As near as I can tell, there's no standard in the cgi spec as to how this
should be done. CERN is particularly problematic. There appears to be a
MaxContentLengthBuffer that defaults to 50K if not reset in the config
file. CERN takes all of the output of the cgi program and shoves it into
this buffer so that it can get the total length of the document and place
this figure in the status line.

The problem comes when you have sufficient material so that your
length exceeds the length of this buffer. CERN has to make more than
one pass to get it all. In between passes, your cgi script is suspended
in mid-air because it was called as a piped process. Unless the parent
is ready to receive from the child, the child waits patiently. There's
nothing you can do about this that I'm aware of. The problem seems to
be when the user aborts while your child process is hung between buffers.

I tried putting an alarm(60) in my cgi program (which is written in C),
and then capturing this alarm and exiting. It never takes my program
longer than 2 seconds to produce all its data, so it seemed reasonable to
exit after 60 seconds.  This trick works stand-alone, even under test
conditions imposed by a long sleep(), but the CERN setup defeats this for
reasons I don't understand. There was no change in behavior; my program
still hung, same as before. Apparently the httpd gets a SIGPIPE signal
when the user aborts, but what it does with this in terms of the child
process is a different question entirely.

What I ended up doing is counting the lines in my output, and when I
hit 40K, I tell the user to narrow their search parameters. This works
with my particular application. I haven't seen any hangs when this setup
is used.

If you have access to the CERN configuration, which I don't, you can
try changing the MaxContentLengthBuffer and see if that fixes your
problem. Please let me know what you come up with.

I could be wrong about my interpretation above, but it's the best I
could come up with, given my limited knowledge of Linux and C.

-- Daniel Brandt

----------------------------------------------------------------------
Public Information Research, Inc., PO Box 680635, San Antonio TX 78268
Tel:210-509-3160   Fax:210-509-3161    Nonprofit publisher of NameBase
   NameBase Online:    telnet ursula.blythe.org     login: namebase
NameBase home page:    http://ursula.blythe.org/NameBase/bookindx.html
----------------------------------------------------------------------

 
 
 

Bug(?) with cgi scripts under CERN httpd

Post by Chris Osbo » Tue, 20 Feb 1996 04:00:00




Quote:>What I ended up doing is counting the lines in my output, and when I
>hit 40K, I tell the user to narrow their search parameters. This works
>with my particular application. I haven't seen any hangs when this setup
>is used.

>If you have access to the CERN configuration, which I don't, you can
>try changing the MaxContentLengthBuffer and see if that fixes your
>problem. Please let me know what you come up with.

This seems to explain why it's only one particular URL that causes
this problem, and none of the rest. The one I'm having problems with
spits out 70k of data.

What I tried to do yesterday was added a Content-Length header to the
cgi script, so it'd spit out the length of the data it was going to
return. Didn't help. I was at least hoping users would see how long it
was, and go ahead and let it finish.

I tried your suggestion of the MaxContentLengthBuffer, and bumped it
up to 100k. Didn't help. Looking at the docs, it says it's for doing
proxies, not regular use.

This really sucks, because within about a day, I've got so many nobody
processes* that it can't fork anymore, and users can't get the
information they're looking for.

--
Chris Osborn, Network Administrator       Voice: 707 253 3130
Napa Valley College                         Fax: 707 253 3063
2277 Napa-Vallejo Hwy., Napa, CA, 94558

 
 
 

1. CERN httpd & user CGI scripts

Hello.  Can someone out there PLEASE give me a hand.  Is there anyway to configure
CERN httpd to let users run cgi scripts from their own account.  I know with NCSA
httpd, you could put the following in the access.conf file:
<Directory /user/joe>
Options execCGI Indexes
</Directory>

Is there anything like this in the CERN httpd?  Thanks to anyone who can help! :)

-Jason

2. Installing a manpage

3. Perl CGI scripts under CERN HTTPD and Digital UNIX V3.2

4. Running NACHOS on Linux.

5. CERN httpd / cgi scripts failing sporadically

6. semaphore

7. CERN httpd: ACL on CGI-scripts?

8. PC-Term direct-wired via Serial Port?

9. Problem executing CGI scripts with CERN httpd

10. CERN Httpd CGI Timeout

11. CERN httpd: cgi & pid problem - HELP?!?

12. Cern httpd 3.0 cgi-bin

13. Perl CGI Fails with Apache but Runs with CERN HTTPD