-sub getline_response ($$) {
- my ($self, $alive) = @_;
- my $write = $alive == 2 ? \&chunked_write : \&identity_write;
- my $pull; # DANGER: self-referential
- $pull = sub {
- my $forward = $self->{forward};
- # limit our own running time for fairness with other
- # clients and to avoid buffering too much:
- my $buf = eval {
- local $/ = \8192;
- $forward->getline;
- } if $forward;
-
- if (defined $buf) {
- # may close in PublicInbox::DS::write
- $write->($self, $buf);
-
- if ($self->{sock}) {
- my $wbuf = $self->{wbuf} ||= [];
- push @$wbuf, $pull;
-
- # wbuf may be populated by $write->(...$buf),
- # no need to rearm if so:
- $self->requeue if scalar(@$wbuf) == 1;
- return; # likely
- }
- } elsif ($@) {
- err($self, "response ->getline error: $@");
- $self->close;
+sub getline_pull {
+ my ($self) = @_;
+ my $forward = $self->{forward};
+
+ # limit our own running time for fairness with other
+ # clients and to avoid buffering too much:
+ my $buf = eval {
+ local $/ = \8192;
+ $forward->getline;
+ } if $forward;
+
+ if (defined $buf) {
+ # may close in PublicInbox::DS::write
+ if ($self->{alive} == 2) {
+ chunked_write($self, $buf);
+ } else {
+ identity_write($self, $buf);