]> Sergey Matveev's repositories - public-inbox.git/commitdiff
httpd/async: avoid unnecessary on-stack delete
authorEric Wong <e@80x24.org>
Sun, 7 Feb 2021 08:52:01 +0000 (08:52 +0000)
committerEric Wong <e@80x24.org>
Sun, 7 Feb 2021 22:57:30 +0000 (22:57 +0000)
While this doesn't fix a known problem, this was a risky
construct in case somebody uses confess/longmess inside
the user-supplied callback.

cf. commit 0795b0906cc81f40
    ("ds: guard against stack-not-refcounted quirk of Perl 5")

lib/PublicInbox/HTTPD/Async.pm

index 1de9501d18c43528e4ce634458b394d089d6eb41..7238650aff978605c53213fdd5586f32465f785b 100644 (file)
@@ -46,7 +46,7 @@ sub event_step {
        my ($self) = @_;
        if (my $cb = delete $self->{cb}) {
                # this may call async_pass when headers are done
-               $cb->(delete $self->{arg});
+               $cb->(my $refcnt_guard = delete $self->{arg});
        } elsif (my $sock = $self->{sock}) {
                my $http = $self->{http};
                # $self->{sock} is a read pipe for git-http-backend or cgit