]> Sergey Matveev's repositories - public-inbox.git/commitdiff
qspawn: use ->DESTROY to force ->finalize
authorEric Wong <e@80x24.org>
Wed, 18 Jan 2023 02:10:11 +0000 (02:10 +0000)
committerEric Wong <e@80x24.org>
Wed, 18 Jan 2023 23:25:57 +0000 (23:25 +0000)
There's apparently a few places where we do not call ->finalize
or ->finish and leave dangling limiter slots occupied.  I can't
reproduce this easily, so it's likely in error-handling paths.

I already made ->finalize idempotent when switching to awaitpid
since I wanted to rely entirely on DESTROY.  However, DESTROY
doesn't always fire soon enough (and the client has already seen
a response), but using DESTROY as a fallback seems reasonable..

This does the minimum to ensure the limiter is freed up on
process exit, but ensuring a finish/finalize call always happens
is the goal.

lib/PublicInbox/Qspawn.pm

index 02357dbf83988fb4db2c2223a9f0a58dca17187f..78afe718d26dd21ce0d49ec60d86679d92a5f146 100644 (file)
@@ -104,6 +104,8 @@ sub finalize ($) {
        }
 }
 
+sub DESTROY { finalize($_[0]) } # ->finalize is idempotent
+
 sub waitpid_err { # callback for awaitpid
        my (undef, $self) = @_; # $_[0]: pid
        $self->{_err} = ''; # for defined check in ->finish