From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E16C51F619 for ; Sat, 10 Sep 2022 08:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1662797931; bh=R86ZfPYwYS71SQZN699qivcJ2C3FhPRE+bNuyOY6uX4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tNzuFXPm1C5m+CX3Oc0GfHw5Xet4eGKG/fcU4xJb7Ld2xVxtfyTTC3Cbtn1nKSRm+ nTiHTTynfSOLECPCJR09FZ7wmvz/HF7+UEe3JO1ceuqr3vevSVZ7rR4xoHjf36JZVa sgSlDDIoobJnXDKLQjOVEGEnuLHPcgV45riSiWBM= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 02/38] www: gzip_filter: implicitly flush {obuf} on zmore/zflush Date: Sat, 10 Sep 2022 08:16:53 +0000 Message-Id: <20220910081729.2011934-3-e@80x24.org> In-Reply-To: <20220910081729.2011934-1-e@80x24.org> References: <20220910081729.2011934-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This seems like the least disruptive way to allow more use of ->zmore when streaming large messages to sockets. --- lib/PublicInbox/CompressNoop.pm | 4 ++-- lib/PublicInbox/GzipFilter.pm | 9 +++++---- lib/PublicInbox/ViewVCS.pm | 2 -- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/PublicInbox/CompressNoop.pm b/lib/PublicInbox/CompressNoop.pm index e3301473..5135299f 100644 --- a/lib/PublicInbox/CompressNoop.pm +++ b/lib/PublicInbox/CompressNoop.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2020-2021 all contributors +# Copyright (C) all contributors # License: AGPL-3.0+ # Provide the same methods as Compress::Raw::Zlib::Deflate but @@ -10,7 +10,7 @@ use Compress::Raw::Zlib qw(Z_OK); sub new { bless \(my $self), __PACKAGE__ } sub deflate { # ($self, $input, $output) - $_[2] .= $_[1]; + $_[2] .= ref($_[1]) ? ${$_[1]} : $_[1]; Z_OK; } 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 diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm index 3b4fa393..ed4a6454 100644 --- a/lib/PublicInbox/ViewVCS.pm +++ b/lib/PublicInbox/ViewVCS.pm @@ -210,8 +210,6 @@ EOM $x =~ s/\r?\n/\n/gs; $ctx->{-anchors} = {} if $x =~ /^diff --git /sm; flush_diff($ctx, \$x); # undefs $x - $ctx->zmore($bdy); - undef $bdy; # TODO: should there be another textarea which attempts to # search for the exact email which was applied to make this # commit?