From 63d2e98ce28ddfefeac8bfdac409eae5efc03a9f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 9 Jul 2016 04:51:37 +0000 Subject: httpd/async: reinstate D::S timer usage for cleanup EvCleanup::asap events are not guaranteed to run after Danga::Socket closes sockets at the event loop. Thus we must use slower Danga::Socket timers which are guaranteed to run at the end of the event loop. --- lib/PublicInbox/EvCleanup.pm | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/PublicInbox/EvCleanup.pm') diff --git a/lib/PublicInbox/EvCleanup.pm b/lib/PublicInbox/EvCleanup.pm index 61837b89..2b77c617 100644 --- a/lib/PublicInbox/EvCleanup.pm +++ b/lib/PublicInbox/EvCleanup.pm @@ -9,6 +9,7 @@ use base qw(Danga::Socket); use fields qw(rd); my $singleton; my $asapq = [ [], undef ]; +my $nextq = [ [], undef ]; my $laterq = [ [], undef ]; sub once_init () { @@ -30,6 +31,7 @@ sub _run_all ($) { } sub _run_asap () { _run_all($asapq) } +sub _run_next () { _run_all($nextq) } sub _run_later () { _run_all($laterq) } # Called by Danga::Socket @@ -51,6 +53,12 @@ sub asap ($) { $asapq->[1] ||= _asap_timer(); } +sub next_tick ($) { + my ($cb) = @_; + push @{$nextq->[0]}, $cb; + $nextq->[1] ||= Danga::Socket->AddTimer(0, *_run_next); +} + sub later ($) { my ($cb) = @_; push @{$laterq->[0]}, $cb; @@ -59,6 +67,7 @@ sub later ($) { END { _run_asap(); + _run_next(); _run_later(); } -- cgit v1.2.3-24-ge0c7