about summary refs log tree commit homepage
path: root/lib/PublicInbox/GzipFilter.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-09-10 08:16:53 +0000
committerEric Wong <e@80x24.org>2022-09-10 19:50:25 +0000
commit133c9c61c0fe7e0e2d8d00e9935b3433b806ddc7 (patch)
tree3d8bccc83610cd77f64024244adeb090d4d6bd15 /lib/PublicInbox/GzipFilter.pm
parentbb3e51c9fdaf1059c2ae8368a527b4bd87b0b423 (diff)
downloadpublic-inbox-133c9c61c0fe7e0e2d8d00e9935b3433b806ddc7.tar.gz
This seems like the least disruptive way to allow more use of
->zmore when streaming large messages to sockets.
Diffstat (limited to 'lib/PublicInbox/GzipFilter.pm')
-rw-r--r--lib/PublicInbox/GzipFilter.pm9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/PublicInbox/GzipFilter.pm b/lib/PublicInbox/GzipFilter.pm
index 86d34183..75ba625e 100644
--- a/lib/PublicInbox/GzipFilter.pm
+++ b/lib/PublicInbox/GzipFilter.pm
@@ -140,8 +140,8 @@ sub zmore {
         my $self = $_[0]; # $_[1] => input
         http_out($self);
         my $err;
-        for (1..$#_) {
-                $err = $self->{gz}->deflate($_[$_], $self->{zbuf});
+        for (delete $self->{obuf}, @_[1..$#_]) {
+                $err = $self->{gz}->deflate($_ // next, $self->{zbuf});
                 die "gzip->deflate: $err" if $err != Z_OK;
         }
         undef;
@@ -153,8 +153,9 @@ sub zflush ($;@) {
         my $zbuf = delete $self->{zbuf};
         my $gz = delete $self->{gz};
         my $err;
-        for (1..$#_) { # it's a bug iff $gz is undef w/ $_[1..]
-                $err = $gz->deflate($_[$_], $zbuf);
+        # it's a bug iff $gz is undef w/ $obuf or $_[1..]
+        for (delete $self->{obuf}, @_[1..$#_]) {
+                $err = $gz->deflate($_ // next, $zbuf);
                 die "gzip->deflate: $err" if $err != Z_OK;
         }
         $gz // return ''; # not a bug, recursing on DS->write failure