- if ($alive) {
- $self->event_write; # watch for readability if done
- } else {
- Danga::Socket::write($self, sub { $self->close });
+ $self->write(sub{$alive ? next_request($self) : $self->close});
+ }
+}
+
+sub getline_cb ($$$) {
+ my ($self, $write, $close) = @_;
+ local $/ = \8192;
+ my $forward = $self->{forward};
+ # limit our own running time for fairness with other
+ # clients and to avoid buffering too much:
+ if ($forward) {
+ my $buf = eval { $forward->getline };
+ if (defined $buf) {
+ $write->($buf); # may close in Danga::Socket::write
+ unless ($self->{closed}) {
+ my $next = $self->{pull};
+ if ($self->{write_buf_size}) {
+ $self->write($next);
+ } else {
+ PublicInbox::EvCleanup::asap($next);
+ }
+ return;
+ }
+ } elsif ($@) {
+ err($self, "response ->getline error: $@");
+ $forward = undef;
+ $self->close;