use Carp qw(croak confess carp);
require File::Spec;
+my $nextt; # timer for next_tick
+my $nextq = []; # queue for next_tick
our (
%DescriptorMap, # fd (num) -> PublicInbox::DS object
$Epoll, # Global epoll fd (or DSKQXS ref)
}
}
+sub next_tick () {
+ $nextt = undef;
+ my $q = $nextq;
+ $nextq = [];
+ $_->event_step for @$q;
+}
+
+sub requeue ($) {
+ push @$nextq, $_[0];
+ $nextt ||= PublicInbox::EvCleanup::asap(*next_tick);
+}
+
package PublicInbox::DS::Timer;
# [$abs_float_firetime, $coderef];
sub cancel {
my $EXPMAP; # fd -> [ idle_time, $self ]
my $expt;
our $EXPTIME = 180; # 3 minutes
-my $nextt;
-
-my $nextq = [];
-sub next_tick () {
- $nextt = undef;
- my $q = $nextq;
- $nextq = [];
- event_step($_) for @$q;
-}
-
-sub requeue ($) {
- push @$nextq, $_[0];
- $nextt ||= PublicInbox::EvCleanup::asap(*next_tick);
-}
sub update_idle_time ($) {
my ($self) = @_;
push @$wbuf, $long_cb;
# wbuf may be populated by $cb, no need to rearm if so:
- requeue($self) if scalar(@$wbuf) == 1;
+ $self->requeue if scalar(@$wbuf) == 1;
} else { # all done!
$long_cb = undef;
res($self, '.');
out($self, " deferred[$fd] done - %0.6f", now() - $t0);
- requeue($self) unless $self->{wbuf};
+ $self->requeue unless $self->{wbuf};
}
};
$self->write($long_cb); # kick off!
return '580 can not initiate TLS negotiation';
res($self, '382 Continue with TLS negotiation');
$self->{sock} = IO::Socket::SSL->start_SSL($sock, %$opt);
- requeue($self) if PublicInbox::DS::accept_tls_step($self);
+ $self->requeue if PublicInbox::DS::accept_tls_step($self);
undef;
}
# maybe there's more pipelined data, or we'll have
# to register it for socket-readiness notifications
- requeue($self) unless $self->{wbuf};
+ $self->requeue unless $self->{wbuf};
}
sub not_idle_long ($$) {