diff options
author | Eric Wong <e@80x24.org> | 2021-10-16 01:00:54 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-10-16 01:42:49 +0000 |
commit | a1a8cbab22adec879f97dccd9acfd0c5b2492ba9 (patch) | |
tree | 78647cecb223c4116634fee548de9c075ef574f3 /lib/PublicInbox/DS.pm | |
parent | f64adbd5e3c35197c1915bca108cdcd81f74f708 (diff) | |
download | public-inbox-a1a8cbab22adec879f97dccd9acfd0c5b2492ba9.tar.gz |
It's needlessly complex and O(n), so it doesn't scale well to a high number of clients nor is it easy-to-scale with the data structures available to us in pure Perl. In any case, I see no evidence of either -imapd nor -nntpd experiencing high connection loads on public-facing sites. -httpd has never had its own timer-based expiration, either. Fwiw, public-inbox.org itself has been running a public-facing HTTP/HTTPS server with no userspace idle client expiration for the past 8 years or with no ill effect. Clients can come and go as they wish, and SO_KEEPALIVE takes care of truly broken connections if they're gone for ~2 hours. Internet connections drop all time, so it should be harmless to drop connections w/o warning since both NNTP and IMAP protocols have well-defined semantics for determining if a message was truncated (as does HTTP/1.1+).
Diffstat (limited to 'lib/PublicInbox/DS.pm')
-rw-r--r-- | lib/PublicInbox/DS.pm | 37 |
1 files changed, 1 insertions, 36 deletions
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 9cca02d7..bf8c4466 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -37,9 +37,7 @@ our @EXPORT_OK = qw(now msg_more dwaitpid add_timer add_uniq_timer); my %Stack; my $nextq; # queue for next_tick my $wait_pids; # list of [ pid, callback, callback_arg ] -my $EXPMAP; # fd -> idle_time -our $EXPTIME = 180; # 3 minutes -my ($reap_armed); +my $reap_armed; my $ToClose; # sockets to close when event loop is done our ( %DescriptorMap, # fd (num) -> PublicInbox::DS object @@ -76,7 +74,6 @@ sub Reset { # we may be iterating inside one of these on our stack my @q = delete @Stack{keys %Stack}; for my $q (@q) { @$q = () } - $EXPMAP = undef; $wait_pids = $nextq = $ToClose = undef; $ep_io = undef; # closes real $Epoll FD $Epoll = undef; # may call DSKQXS::DESTROY @@ -251,9 +248,6 @@ sub PostEventLoop () { $ToClose = undef; # will be autovivified on push @$close_now = map { fileno($_) } @$close_now; - # order matters, destroy expiry times, first: - delete @$EXPMAP{@$close_now}; - # ->DESTROY methods may populate ToClose delete @DescriptorMap{@$close_now}; } @@ -655,35 +649,6 @@ sub dwaitpid ($;$$) { } } -sub expire_old () { - my $cur = $EXPMAP or return; - $EXPMAP = undef; - my $old = now() - $EXPTIME; - while (my ($fd, $idle_at) = each %$cur) { - if ($idle_at < $old) { - my $ds_obj = $DescriptorMap{$fd}; - $EXPMAP->{$fd} = $idle_at if !$ds_obj->shutdn; - } else { - $EXPMAP->{$fd} = $idle_at; - } - } - add_uniq_timer('expire', 60, \&expire_old) if $EXPMAP; -} - -sub update_idle_time { - my ($self) = @_; - my $sock = $self->{sock} or return; - $EXPMAP->{fileno($sock)} = now(); - add_uniq_timer('expire', 60, \&expire_old); -} - -sub not_idle_long { - my ($self, $now) = @_; - my $sock = $self->{sock} or return; - my $idle_at = $EXPMAP->{fileno($sock)} or return; - ($idle_at + $EXPTIME) > $now; -} - 1; =head1 AUTHORS (Danga::Socket) |