Hi

I tested HTTP::Prox (proxy.pl) on w2k. It works but very very slow (miutes for one web site). The main loop of HTTP::Proxy looks like (see below).

What could be the reason for the slow behaviour on w2k ? (on linux it is pretty fast).

any idea ?

Thanks Matthias



sub start {
    my $self = shift;
    my @kids;

    # some initialisation
    $self->init;
    $SIG{INT} = $SIG{KILL} = sub { $self->{loop} = 0 };

    # the main loop
    my $select = IO::Select->new( $self->daemon );
    while ( $self->loop ) {

        # check for new connections
        my @ready = $select->can_read(0.01);
        for my $fh (@ready) {    # there's only one, anyway

# single-process proxy (useful for debugging)
if ( $self->maxchild == 0 ) {
$self->maxserve(1); # do not block simultaneous connections
$self->log( PROCESS, "No fork allowed, serving the connection" );
$self->serve_connections($fh->accept);
$self->{conn}++; # read-only attribute
next;
}


            if ( @kids >= $self->maxchild ) {
                $self->log( PROCESS, "Too many child process" );
                select( undef, undef, undef, 1 );
                last;
            }

            # accept the new connection
            my $conn  = $fh->accept;
            my $child = fork;
            if ( !defined $child ) {
                $conn->close;
                $self->log( ERROR, "Cannot fork" );
                $self->maxchild( $self->maxchild - 1 )
                  if $self->maxchild > @kids;
                next;
            }

            # the parent process
            if ($child) {
                $conn->close;
                $self->log( PROCESS, "Forked child process $child" );
                push @kids, $child;
            }

            # the child process handles the whole connection
            else {
                $SIG{INT} = 'DEFAULT';
                $self->serve_connections($conn);
                exit;    # let's die!
            }
        }

        # handle zombies
        $self->_reap( [EMAIL PROTECTED] ) if @kids;

        # this was the last child we forked
        last if $self->maxconn && $self->conn >= $self->maxconn;
    }

    # wait for remaining children
    kill INT => @kids;
    $self->_reap( [EMAIL PROTECTED] ) while @kids;

    $self->log( STATUS, "Processed " . $self->conn . " connection(s)" );
    return $self->conn;
}


_______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to