develooper Front page | perl.perl5.porters | Postings from December 2000

[ID 19991004.002] server exits early

Thread Next
From:
Stephen P. Potter
Date:
December 21, 2000 10:57
Subject:
[ID 19991004.002] server exits early
Message ID:
200012211957.OAA13765@spotter.yi.org
This bug still seems to be present in 5.7.0@8221, only on Solaris.

-spp

We have encountered a very interesting problem on which you are really our
last resort:

Exiting a child in a forking server (example on page 194 of 'Advanced Perl
Programming' O'Reilly) seems to clean-up the server socket of the parent on
newer levels of Solaris. The parent exits with a 'EBADF (Bad file number)'
after having served one client request.

We have tried almost everything within our power, e.g.:

*       compiling Perl on a working OS level and copying the binaries to
	the non-working OS level,
*       compiling the current development version (5.005_61),
*       different GNU compilers (2.8.1 and 2.95.1),
*       SUN Workshop Compiler C/C++ 4.2,
*       hacking in 'config.sh' (e.g. 'usevfork=false/true',
	multithreaded/non-multithreaded). 

Nothing works out.

After issuing a bug report, SUN responded with the following:
  <<FW: Bug ID# 4146098>> 
but this is to low-level for us to understand what's really going on. The
troubling patch from SUN seems to be 105210-17 or above.

In more understandable language they claimed that older versions of Solaris
had a bug, which is fixed in newer releases and that Perl has probably been
working around that bug. Now the bug is removed from the OS , Perl is still
working around, but this time unsuccesfully.

Server.pl:
 #!/usr/bin/perl

 use IO::Socket;

 $SIG{CHLD} = sub { wait() };

 $Sock = new IO::Socket::INET( LocalPort => 9000, Proto => 'tcp', Listen =>
 SOMAXCONN, Reuse => 1 ) or die "SOCKET() error [$!]";

 while ( $NewSock = $Sock->accept() )
 {
         $Pid = fork();

         if ( $Pid == 0 )
         {
                 while ( defined( $Buffer = <$NewSock> ) )
                 {
                         print( $Buffer );
                 }

                 exit( 0 );
         }
 }

 close( $Sock );

 exit( 0 );

 Client.pl:
 #!/usr/bin/perl

 use IO::Socket;

 $Sock = new IO::Socket::INET( PeerAddr => 'tsesun01', PeerPort => 9000,
 Proto => 'tcp' ) or die "SOCKET() error [$!]";

 foreach ( 1..10 )
 {
         print( $Sock "Msg $_: How are you ?\n" );
 }

 close( $Sock );

 exit( 0 );

 Output on Solaris 2.6:

 nl1sahd1:root> ./Server.pl
 nl1sahd1:root> jobs
 [1] +  Running                 ./Server.pl &
 nl1sahd1:root> ./Client.pl 
 nl1sahd1:root> Msg 1: How are you ?
 Msg 2: How are you ?
 Msg 3: How are you ?
 Msg 4: How are you ?
 Msg 5: How are you ?
 Msg 6: How are you ?
 Msg 7: How are you ?
 Msg 8: How are you ?
 Msg 9: How are you ?
 Msg 10: How are you ?

 nl1sahd1:root> jobs
 [1] +  Running                 ./Server.pl &

 Server serves as many requests as it should be.

 Output on Solaris 2.7:

 tsesun01:root> ./Server.pl &
 [1]     12331
 tsesun01:root> jobs
 [1] +  Running                 ./Server.pl &
 tsesun01:root> ./Client.pl 
 Msg 1: How are you ?
 Msg 2: How are you ?
 tsesun01:root> Msg 3: How are you ?
 Msg 4: How are you ?
 Msg 5: How are you ?
 Msg 6: How are you ?
 Msg 7: How are you ?
 Msg 8: How are you ?
 Msg 9: How are you ?
 Msg 10: How are you ?

 [1] +  Done                    ./Server.pl &
 tsesun01:root> jobs

 Server only serves one request and ends !!!!!



Thread Next


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