about summary refs log tree commit homepage
path: root/lib/PublicInbox/DS.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-06-24 02:52:45 +0000
committerEric Wong <e@80x24.org>2019-06-24 05:26:27 +0000
commitca6b59974a0f2e24a1d569d118b55c4fc66ff7a3 (patch)
tree701072bf3f9de8e4873a601f11425be832e74e5d /lib/PublicInbox/DS.pm
parent87a03babc14247d4eac489beb95abba47cf4f358 (diff)
downloadpublic-inbox-ca6b59974a0f2e24a1d569d118b55c4fc66ff7a3.tar.gz
ds: allow ->write callbacks to syswrite directly
We can bypass buffering when wbuf is empty when it's called
from a CODE reference passed to ->write.
Diffstat (limited to 'lib/PublicInbox/DS.pm')
-rw-r--r--lib/PublicInbox/DS.pm3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 2aa9e3d2..0e48ed07 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -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 {