develooper Front page | perl.perl5.porters | Postings from September 2001

Re: [ID 20010903.004] accept() cores interpreter

From:
Daniel Corbe
Date:
September 3, 2001 21:42
Subject:
Re: [ID 20010903.004] accept() cores interpreter
Message ID:
Pine.BSF.4.33.0109032017570.1955-100000@atlantis.corbe.net

You're absolutly right, I didn't catch that.  sock is supposed to be a
temporary variable: so doing something along the lines of:

                        if ($socklist->{$i}->{sv})
                        {
                                undef $sock;            # Our temporary variable
                                accept($sock, $socklist->{$i}->{fh});

fixes my original problem.  I apologize for the oversite.

On Tue, 4 Sep 2001, Graham Barr wrote:

> On Mon, Sep 03, 2001 at 07:08:04PM -0400, Michael G Schwern wrote:
> > On Mon, Sep 03, 2001 at 04:32:37AM -0000, corbe@atlantis.corbe.net wrote:
> > > This little tidbit of code seems to core the perl interpreter.  A
> > > copy of the core file can be furnished upon request.
> >
> > This continues to core on 5.6.1, but bleadperl has fixed it.
> >
> > Can anyone cut that code down a bit into something testable?
>
> Yes. Reading the code they are passing the listen socket as both arguments
> to accept. So thier code is essentially
>
>
> #!/usr/bin/perl
>
> use strict;
> use Socket;
> use Fcntl;
>
> my $rin = '';	# Read set
>
> # Temporary variables
> my $sock;
> my $fileno;
> my($rout, $eout);
>
> # Create the listening socket
> my $proto = getprotobyname('tcp');
> socket($sock, PF_INET, SOCK_STREAM, $proto);
> setsockopt($sock, SOL_SOCKET, SO_REUSEADDR, 1);
> my $paddr = sockaddr_in(2999, INADDR_ANY);
> bind($sock, $paddr);
> listen($sock, SOMAXCONN);
>
> # Prepare the event loop
> $fileno = fileno($sock);		# Store sock's fileno for vec()
> vec($rin, $fileno, 1) = 1;		# Add listening sock to read set
>
> ($rout, $eout) = $rin;
> select($rout, undef, $eout, undef);
> accept($sock, $sock);
>
>
> Graham.
>




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