From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] tick
Date: Wed, 14 Dec 2016 19:28:30 +0000 [thread overview]
Message-ID: <20161214192830.GA7305@starla> (raw)
---
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
reply other threads:[~2016-12-14 19:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161214192830.GA7305@starla \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).