AxKit2

 view release on metacpan or  search on metacpan

lib/AxKit2/Connection.pm  view on Meta::CPAN

    $self->{headers_string}        = '';
    $self->{headers_in}            = undef;
    $self->{headers_out}           = undef;
    $self->{http_headers_sent}     = 0;
    $self->{notes}                 = {};
    $self->{path_config}           = undef;
    
    # NOTE: because we only speak 1.0 to clients they can't have
    # pipeline in a read that we haven't read yet.
    $self->watch_read(1);
    $self->watch_write(0);
    
    $self->hook_pre_request();
    
    return 1;
}

sub DESTROY {
#    print "Connection DESTROY\n";
}

Danga::Socket->AddTimer(CLEANUP_TIME, \&_do_cleanup);

# Cleanup routine to get rid of timed out sockets
sub _do_cleanup {
    my $now = time;
    
    # AxKit2::Client->log(LOGDEBUG, "do cleanup");
    
    Danga::Socket->AddTimer(CLEANUP_TIME, \&_do_cleanup);
    
    my $sf = __PACKAGE__->get_sock_ref;
    
    my $conns = 0;

    my %max_age;  # classname -> max age (0 means forever)
    my %max_connect; # classname -> max connect time
    my @to_close;
    while (my $k = each %$sf) {
        my AxKit2::Connection $v = $sf->{$k};
        my $ref = ref $v;
        next unless $v->isa('AxKit2::Connection');
        $conns++;
        unless (defined $max_age{$ref}) {
            $max_age{$ref}      = $ref->max_idle_time || 0;
            $max_connect{$ref}  = $ref->max_connect_time || 0;
        }
        if (my $t = $max_connect{$ref}) {
            if ($v->{create_time} < $now - $t) {
                push @to_close, $v;
                next;
            }
        }
        if (my $t = $max_age{$ref}) {
            if ($v->{alive_time} < $now - $t) {
                push @to_close, $v;
            }
        }
    }
    
    $_->close("Timeout") foreach @to_close;
}

1;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.163 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )