From 4685b1d88ffe1f18334bfdd12977ece1fe9d11ce Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 10 Jul 2019 06:13:59 +0000 Subject: http|nntp: avoid recursion inside ->write In HTTP.pm, we can use the same technique NNTP.pm uses with long_response with the $long_cb callback and avoid storing $pull in the per-client structure at all. We can also reuse the same logic to push the callback into wbuf from NNTP. This does NOT introduce a new circular reference, but documents it more clearly. --- lib/PublicInbox/NNTP.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/PublicInbox/NNTP.pm') diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index 6796a3c4..f4208f87 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -658,7 +658,8 @@ sub long_response ($$) { $long_cb = undef; res($self, '.'); out($self, " deferred[$fd] done - %0.6f", now() - $t0); - $self->requeue unless $self->{wbuf}; + my $wbuf = $self->{wbuf}; + $self->requeue unless $wbuf && @$wbuf; } }; $self->write($long_cb); # kick off! -- cgit v1.2.3-24-ge0c7