]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/HTTPD/Async.pm
ds: get rid of event_watch field
[public-inbox.git] / lib / PublicInbox / HTTPD / Async.pm
index 46ea188c0127c8a0791015b1d475861f6aff9a39..f32ef0093869a1e910ed3145e283d3b52ba8e4bc 100644 (file)
@@ -25,17 +25,18 @@ sub new {
 
        my $self = fields::new($class);
        IO::Handle::blocking($io, 0);
-       $self->SUPER::new($io);
+       $self->SUPER::new($io, PublicInbox::DS::EPOLLIN());
        $self->{cb} = $cb;
        $self->{cleanup} = $cleanup;
-       $self->watch_read(1);
        $self;
 }
 
+sub restart_read ($) { $_[0]->watch(PublicInbox::DS::EPOLLIN()) }
+
 # fires after pending writes are complete:
 sub restart_read_cb ($) {
        my ($self) = @_;
-       sub { $self->watch_read(1) }
+       sub { restart_read($self) }
 }
 
 sub main_cb ($$$) {
@@ -47,16 +48,16 @@ sub main_cb ($$$) {
                        $fh->write($$bref);
                        if ($http->{sock}) { # !closed
                                if ($http->{wbuf}) {
-                                       $self->watch_read(0);
+                                       $self->watch(0);
                                        $http->write(restart_read_cb($self));
                                }
-                               # stay in watch_read, but let other clients
+                               # stay in EPOLLIN, but let other clients
                                # get some work done, too.
                                return;
                        }
                        # fall through to close below...
                } elsif (!defined $r) {
-                       return if $!{EAGAIN} || $!{EINTR};
+                       return restart_read($self) if $!{EAGAIN} || $!{EINTR};
                }
 
                # Done! Error handling will happen in $fh->close