]> 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 a647f10d5f002067891301eb91a348b107c04ef3..f32ef0093869a1e910ed3145e283d3b52ba8e4bc 100644 (file)
@@ -8,7 +8,7 @@
 package PublicInbox::HTTPD::Async;
 use strict;
 use warnings;
-use base qw(Danga::Socket);
+use base qw(PublicInbox::DS);
 use fields qw(cb cleanup);
 require PublicInbox::EvCleanup;
 
@@ -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 ($$$) {
@@ -45,18 +46,18 @@ sub main_cb ($$$) {
                my $r = sysread($self->{sock}, $$bref, 8192);
                if ($r) {
                        $fh->write($$bref);
-                       unless ($http->{closed}) { # Danga::Socket sets this
-                               if ($http->{write_buf_size}) {
-                                       $self->watch_read(0);
+                       if ($http->{sock}) { # !closed
+                               if ($http->{wbuf}) {
+                                       $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
@@ -75,9 +76,7 @@ sub async_pass {
        $self->{cb} = main_cb($http, $fh, $bref);
 }
 
-sub event_read { $_[0]->{cb}->(@_) }
-sub event_hup { $_[0]->{cb}->(@_) }
-sub event_err { $_[0]->{cb}->(@_) }
+sub event_step { $_[0]->{cb}->(@_) }
 
 sub close {
        my $self = shift;