* [PATCH] tick
@ 2016-12-14 19:28 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-12-14 19:28 UTC (permalink / raw)
To: spew
---
lib/PublicInbox/Daemon.pm | 2 ++
lib/PublicInbox/HTTP.pm | 1 +
lib/PublicInbox/Listener.pm | 9 +++++++--
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index 37aa418..8dedb71 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -485,4 +485,6 @@ sub write_pid ($) {
do_chown($path);
}
+sub tick () { $_->active_tick for @listeners }
+
1;
diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm
index cac14be..25e9015 100644
--- a/lib/PublicInbox/HTTP.pm
+++ b/lib/PublicInbox/HTTP.pm
@@ -65,6 +65,7 @@ sub new ($$$) {
sub event_read { # called by Danga::Socket
my ($self) = @_;
+ PublicInbox::Daemon::tick();
return event_read_input($self) if defined $self->{env};
diff --git a/lib/PublicInbox/Listener.pm b/lib/PublicInbox/Listener.pm
index 5f351a7..c603e61 100644
--- a/lib/PublicInbox/Listener.pm
+++ b/lib/PublicInbox/Listener.pm
@@ -7,7 +7,7 @@ use strict;
use warnings;
use base 'Danga::Socket';
use Socket qw(SOL_SOCKET SO_KEEPALIVE IPPROTO_TCP TCP_NODELAY);
-use fields qw(post_accept);
+use fields qw(post_accept active);
require IO::Handle;
sub new ($$$) {
@@ -28,10 +28,15 @@ sub event_read {
my $sock = $self->{sock};
# no loop here, we want to fairly distribute clients
# between multiple processes sharing the same socket
- if (my $addr = accept(my $c, $sock)) {
+ if (my $addr = $self->{active} = accept(my $c, $sock)) {
IO::Handle::blocking($c, 0); # no accept4 :<
$self->{post_accept}->($c, $addr, $sock);
}
}
+sub active_tick {
+ my ($self) = @_;
+ event_read($self) if $self->{active};
+}
+
1;
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-12-14 19:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-14 19:28 [PATCH] tick Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).