The write buffering will already be processed inside
->event_step, so requeue will cause a needless read(2) outside
of epoll_wait/kevent(2) readiness notifications.
This ought to avoid problems in case of pipelined connections,
but those aren't possible behind a reverse proxy and AFAIK most
HTTP clients don't do pipelining. This bug was only noticed via
strace while searching for extra syscalls, and not from
real-world use.
delete $self->{env}; # we're no longer busy
# HEAD requests set $alive = 3 so we don't send "0\r\n\r\n";
$self->write(\"0\r\n\r\n") if $alive == 2;
- $self->write($alive ? $self->can('requeue') : \&close);
+ $self->write(\&close) if !$alive;
+ $self->requeue if $alive && !$self->{wbuf};
}
sub getline_pull {
}
} elsif ($@) {
warn "response ->getline error: $@";
- $self->close;
+ return $self->close;
}
response_done($self, delete $self->{alive});
}