]> Sergey Matveev's repositories - public-inbox.git/commitdiff
ds: allow ->write callbacks to syswrite directly
authorEric Wong <e@80x24.org>
Mon, 24 Jun 2019 02:52:45 +0000 (02:52 +0000)
committerEric Wong <e@80x24.org>
Mon, 24 Jun 2019 05:26:27 +0000 (05:26 +0000)
We can bypass buffering when wbuf is empty when it's called
from a CODE reference passed to ->write.

lib/PublicInbox/DS.pm

index 2aa9e3d294beae7615b999d88085bc5b2f7e0cd3..0e48ed07cc380e05f811ad919f5f921966dae72b 100644 (file)
@@ -537,7 +537,8 @@ sub write {
     my $sock = $self->{sock} or return 1;
     my $ref = ref $data;
     my $bref = $ref ? $data : \$data;
-    if (my $wbuf = $self->{wbuf}) { # already buffering, can't write more...
+    my $wbuf = $self->{wbuf};
+    if ($wbuf && scalar(@$wbuf)) { # already buffering, can't write more...
         if ($ref eq 'CODE') {
             push @$wbuf, $bref;
         } else {