about summary refs log tree commit homepage
path: root/lib/PublicInbox/NNTP.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-07-10 06:13:59 +0000
committerEric Wong <e@80x24.org>2019-07-10 08:25:06 +0000
commit4685b1d88ffe1f18334bfdd12977ece1fe9d11ce (patch)
tree745eb7d4b0852f7eed8b1e1d50bbfb96df37eddb /lib/PublicInbox/NNTP.pm
parentd5615a3c28aaaa86385c400b01050177b60469a2 (diff)
downloadpublic-inbox-4685b1d88ffe1f18334bfdd12977ece1fe9d11ce.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/NNTP.pm')
-rw-r--r--lib/PublicInbox/NNTP.pm3
1 files changed, 2 insertions, 1 deletions
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!