From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id A9E331FF9D for ; Fri, 16 Oct 2020 07:00:34 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 04/64] git: async: loop inflight checks for nested callbacks Date: Fri, 16 Oct 2020 06:59:34 +0000 Message-Id: <20201016070034.22204-4-e@80x24.org> In-Reply-To: <20201016070034.22204-1-e@80x24.org> References: <20201016070034.22204-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We need to loop the inflight check for nested callback invocations to ensure we don't clog the pipe that feeds `git cat-file'. This bug was obscured by the fact that we're already accounting for 64-char git OIDs with SHA-256 in the pipe space calculation; perhaps we shouldn't do that. --- lib/PublicInbox/Git.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index eb5de159..e3a2bcb8 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -275,7 +275,7 @@ sub check_async_begin ($) { sub check_async ($$$$) { my ($self, $oid, $cb, $arg) = @_; my $inflight_c = $self->{inflight_c} // check_async_begin($self); - if (scalar(@$inflight_c) >= MAX_INFLIGHT) { + while (scalar(@$inflight_c) >= MAX_INFLIGHT) { check_async_step($self, $inflight_c); } print { $self->{out_c} } $oid, "\n" or fail($self, "write error: $!"); @@ -420,10 +420,9 @@ sub cat_async_begin { sub cat_async ($$$;$) { my ($self, $oid, $cb, $arg) = @_; my $inflight = $self->{inflight} // cat_async_begin($self); - if (scalar(@$inflight) >= MAX_INFLIGHT) { + while (scalar(@$inflight) >= MAX_INFLIGHT) { cat_async_step($self, $inflight); } - print { $self->{out} } $oid, "\n" or fail($self, "write error: $!"); push(@$inflight, $oid, $cb, $arg); }