]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
ds: long_response: reduce {long_cb} size
authorEric Wong <e@80x24.org>
Sat, 28 Jun 2025 11:20:13 +0000 (11:20 +0000)
committerEric Wong <e@80x24.org>
Mon, 30 Jun 2025 08:20:41 +0000 (08:20 +0000)
Invoking the `fileno' op should be trivial in cost and we can
reduce the amount of potentially long-lived storage for long
responses by invoking it with every long_step call.

lib/PublicInbox/DS.pm

index 2b4528aea4c34aeee4aec25d59d7c035e16b0c7f..9706d520ead357897ec164c7ba1d5b2f2206699e 100644 (file)
@@ -638,7 +638,8 @@ sub long_response_done {} # overridden by Net::NNTP
 sub long_step {
        my ($self) = @_;
        # wbuf is unset or empty, here; $cb may add to it
-       my ($fd, $cb, $t0, @args) = @{$self->{long_cb}};
+       my $fd = fileno($self->{sock} // return);
+       my ($cb, $t0, @args) = @{$self->{long_cb}};
        my $more = eval { $cb->($self, @args) };
        if ($@ || !$self->{sock}) { # something bad happened...
                delete $self->{long_cb};
@@ -679,7 +680,7 @@ sub long_response ($$;@) {
        # make sure we disable reading during a long response,
        # clients should not be sending us stuff and making us do more
        # work while we are stream a response to them
-       $self->{long_cb} = [ fileno($sock), $cb, now(), @args ];
+       $self->{long_cb} = [ $cb, now(), @args ];
        long_step($self); # kick off!
        undef;
 }