From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 32ECC1F47C; Wed, 18 Jan 2023 02:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1674007811; bh=NweqxoyUICETwoMPO9346on+XfAGjMIaszDuJPOU+tY=; h=Date:From:To:Subject:References:In-Reply-To:From; b=SPpk3Z8Ish2V+Y0QDpwFDHUMIxZrhOiC6MCaW4+ZuWOgaM0w5s1MZ/8YcVE+Ji5Je opa8NyzCHOfXXfNRjxMX/uh00W0UxSgdXwXKaw8jX5bk7SMNRuzPMyprYgLX+Vest+ WDTOgf67N8HWMAeNyNJyJc1VTMRUSK7qrGILlL6A= Date: Wed, 18 Jan 2023 02:10:11 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 13/12] qspawn: use ->DESTROY to force ->finalize Message-ID: <20230118021011.M314217@dcvr> References: <20230117071911.1577890-1-e@80x24.org> <20230117071911.1577890-5-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230117071911.1577890-5-e@80x24.org> List-Id: 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm index 02357dbf..78afe718 100644 --- a/lib/PublicInbox/Qspawn.pm +++ b/lib/PublicInbox/Qspawn.pm @@ -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