use strict;
use v5.10.1;
use parent qw(PublicInbox::DS);
-use PublicInbox::Syscall qw(EPOLLIN EPOLLEXCLUSIVE EPOLLET);
+use PublicInbox::Syscall qw(EPOLLIN EPOLLEXCLUSIVE);
use Errno qw(EAGAIN ECONNRESET);
use IO::Handle (); # blocking
sub new {
- my ($cls, $wq, $field) = @_;
- my $s2 = $wq->{$field // '-wq_s2'} // die "BUG: no {$field}";
- $s2->blocking(0);
- my $self = bless { sock => $s2, wq => $wq }, $cls;
- $self->SUPER::new($s2, EPOLLEXCLUSIVE|EPOLLIN|EPOLLET);
+ my ($cls, $wq, $sock) = @_;
+ $sock->blocking(0);
+ my $self = bless { sock => $sock, wq => $wq }, $cls;
+ $self->SUPER::new($sock, EPOLLEXCLUSIVE|EPOLLIN);
$self;
}
sub event_step {
my ($self) = @_;
- my $n;
- do {
- $n = $self->{wq}->recv_and_run($self->{sock}, 4096 * 33);
- } while ($n);
- return if !defined($n) && $! == EAGAIN; # likely
- warn "wq worker error: $!\n" if !defined($n) && $! != ECONNRESET;
- $self->{wq}->wq_atexit_child if $self->{sock} == $self->{wq}->{-wq_s2};
+ my $n = $self->{wq}->recv_and_run($self->{sock}) and return;
+ unless (defined $n) {
+ return if $! == EAGAIN;
+ warn "recvmsg: $!" if $! != ECONNRESET;
+ }
+ $self->{sock} == $self->{wq}->{-wq_s2} and
+ $self->{wq}->wq_atexit_child;
$self->close; # PublicInbox::DS::close
}