From: Eric Wong Date: Sat, 28 Jun 2025 11:20:13 +0000 (+0000) Subject: ds: long_response: reduce {long_cb} size X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6abff28bfa2011fdcc30b1f248e9ce5333940a8;p=thirdparty%2Fpublic-inbox.git ds: long_response: reduce {long_cb} size 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. --- diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 2b4528aea..9706d520e 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -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; }