unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
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> (raw)
In-Reply-To: <20201016070034.22204-1-e@80x24.org>

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);
 }

  parent reply	other threads:[~2020-10-16  7:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16  6:59 [PATCH 01/64] inbox: add uidvalidity method Eric Wong
2020-10-16  6:59 ` [PATCH 02/64] git: ensure ->destroy clobbers check_async read buffer Eric Wong
2020-10-16  6:59 ` [PATCH 03/64] git: *_async: support nested callback invocations Eric Wong
2020-10-16  6:59 ` Eric Wong [this message]
2020-10-16  7:02 ` oops, :x was supposed to be 1/3 for git: stuff Eric Wong
2020-10-16  7:03 ` [PATCH 01/64] inbox: add uidvalidity method Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201016070034.22204-4-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

unofficial mirror of meta@public-inbox.org

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://yhetil.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.mail.public-inbox.meta
	nntp://news.public-inbox.org/inbox.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git