diff options
author | Eric Wong <e@80x24.org> | 2019-06-24 02:52:22 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-06-24 05:26:26 +0000 |
commit | ca05b93cddfa2cc495451410222af3753bfe1b4e (patch) | |
tree | a6a1b6c437341c82ab3545eeec926956ae76f05c /lib/PublicInbox/HTTP.pm | |
parent | dbcdabe601cfb29c8b7d5f169be9bf560d656a42 (diff) | |
download | public-inbox-ca05b93cddfa2cc495451410222af3753bfe1b4e.tar.gz |
We don't need to keep track of that field since we always know what events we're interested in when using one-shot wakeups.
Diffstat (limited to 'lib/PublicInbox/HTTP.pm')
-rw-r--r-- | lib/PublicInbox/HTTP.pm | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index afa71ea5..773d77ba 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -20,6 +20,7 @@ use HTTP::Date qw(time2str); use IO::Handle; require PublicInbox::EvCleanup; PublicInbox::DS->import(qw(msg_more write_in_full)); +use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT); use constant { CHUNK_START => -1, # [a-f0-9]+\r\n CHUNK_END => -2, # \r\n @@ -56,7 +57,7 @@ sub http_date () { sub new ($$$) { my ($class, $sock, $addr, $httpd) = @_; my $self = fields::new($class); - $self->SUPER::new($sock, PublicInbox::DS::EPOLLIN()); + $self->SUPER::new($sock, EPOLLIN | EPOLLONESHOT); $self->{httpd} = $httpd; $self->{rbuf} = ''; ($self->{remote_addr}, $self->{remote_port}) = @@ -80,7 +81,8 @@ sub event_step { # called by PublicInbox::DS return $self->close if $r == 0; return rbuf_process($self); } - return if $!{EAGAIN}; # no need to call watch_read(1) again + + return $self->watch_in1 if $!{EAGAIN}; # common for clients to break connections without warning, # would be too noisy to log here: @@ -100,7 +102,7 @@ sub rbuf_process { ($r == -2 && length($self->{rbuf}) > 0x4000)) { return quit($self, 400); } - return $self->watch_read(1) if $r < 0; # incomplete + return $self->watch_in1 if $r < 0; # incomplete $self->{rbuf} = substr($self->{rbuf}, $r); my $len = input_prepare($self, \%env); @@ -143,7 +145,6 @@ sub read_input ($) { sub app_dispatch { my ($self, $input) = @_; - $self->watch_read(0); my $env = $self->{env}; $env->{REMOTE_ADDR} = $self->{remote_addr}; $env->{REMOTE_PORT} = $self->{remote_port}; @@ -236,7 +237,7 @@ sub identity_wcb ($) { sub next_request ($) { my ($self) = @_; if ($self->{rbuf} eq '') { # wait for next request - $self->watch_read(1); + $self->watch_in1; } else { # avoid recursion for pipelined requests push @$pipelineq, $self; $pipet ||= PublicInbox::EvCleanup::asap(*process_pipelineq); @@ -360,7 +361,7 @@ sub recv_err { return $self->close if (defined $r && $r == 0); if ($!{EAGAIN}) { $self->{input_left} = $len; - return; + return $self->watch_in1; } err($self, "error reading for input: $! ($len bytes remaining)"); quit($self, 500); |