develooper Front page | perl.macosx | Postings from September 2002

Perl 5.8.0 / Jag broke my servers

From:
Jerry LeVan
Date:
September 15, 2002 12:20
Subject:
Perl 5.8.0 / Jag broke my servers
Message ID:
B9AA55A8.30DE%jerry.levan@eku.edu
Hi,

I have an old perl webserver that I have been carrying around with me for a
number of years. It currently runs fine on Perl 5.6.1 in ³Jaguar². [5.6.1
was compiled in 10.1.5...]

However when I attempt to run the rascal under 5.8.0 the ³accept² statement
is failing...
The code sorta looks like this:

 AGAIN:
  if(!accept(NS,S)) {
# Starting to get accept errors, Connection reset by peer. JHL Jan 16 1997
#     print LOG "Accept Failure, shutting down mhttpd, error: $!\n";
#     exit 1;
     print LOG "Accept Failure, trying again...  $!\n";
     sleep 2; goto AGAIN;
  }

The log entries that show up that are relevant look like:
 Accept Failure, trying again...  No child processes
[15/Sep/02:13:29:23] GET /sql/sqltut.htm HTTP/1.1 From:macjerry
User:(no-connect)
Accept Failure, trying again...  No child processes
[15/Sep/02:13:29:26] GET /sql/sqltut.htm HTTP/1.1 From:macjerry
User:(no-connect)
Accept Failure, trying again...  No child processes
Accept Failure, trying again...  No child processes
[15/Sep/02:13:29:53] GET /index.html HTTP/1.1 From:macjerry
User:(no-connect)
Accept Failure, trying again...  No child processes
[15/Sep/02:13:30:06] GET /oldindex.html HTTP/1.1 From:macjerry
User:(no-connect)
Accept Failure, trying again...  No child processes

This looks like an error from the ³wait² that I do to clean up the child
processes after each request has been satisfied. ³No child processes² is
errno 10 which can be generated by the wait system calls.

[time passes...]

OK, I think I understand the problem...

Since the server is multithreaded ie it forks a child to handle each
incoming request, I have to deal with the death of the child processes. This
was my cleanup code that executed when ever a SIGCHLD signal was received.

# Interupt handler for burying dead children
sub Reaper {
  my $sig = $_[0];
  my $status ;
# SIG{'CHLD'} = 'Reaper';  # uncommnent this in a Sys V environment
#  do {
    $status = waitpid(-1, WNOHANG); # bury children till all are gone
#  } until $status == -1 ;
}

Notice I have commented out the do and until parts so the code will not
loop.
After this change the log looked like:

[15/Sep/02:14:53:11] Starting mhttpd on port 4000
[15/Sep/02:14:53:30] GET / HTTP/1.1 From:macjerry User:(no-connect)
Accept Failure, trying again...  Interrupted system call4

Aha, it now appears that the Accept call was terminated, probably by the
Reaper subroutine
Cleaning up the dead children...

This appears to be different behavior than exhibited in 10.1.5 and perl
5.6.x.

It looks like I will have to test for an interupted system call and the no
child process error after the accept call, sigh...

--Jerry



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About