about summary refs log tree commit homepage
path: root/lib/PublicInbox/GitHTTPBackend.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-07-09 03:18:35 +0000
committerEric Wong <e@80x24.org>2016-07-09 03:20:25 +0000
commit2c972f3d70caf99488fff300341450e48be6ebf1 (patch)
tree066ba4c048b2fb64c271de1bc8096cdca46551ec /lib/PublicInbox/GitHTTPBackend.pm
parentf89bd1444a595b569606679293d2d01b0b7a049e (diff)
downloadpublic-inbox-2c972f3d70caf99488fff300341450e48be6ebf1.tar.gz
Currently only for git-http-backend use, this allows limiting
the number of spawned processes per-inbox or by group, if there
are multiple large inboxes amidst a sea of small ones.

For example, a "big" repo limiter could be used for big inboxes:
which would be shared between multiple repos:

[limiter "big"]
	max = 4
[publicinbox "git"]
	address = git@vger.kernel.org
	mainrepo = /path/to/git.git
	; shared limiter with giant:
	httpbackendmax = big
[publicinbox "giant"]
	address = giant@project.org
	mainrepo = /path/to/giant.git
	; shared limiter with git:
	httpbackendmax = big

; This is a tiny inbox, use the default limiter with 32 slots:
[publicinbox "meta"]
	address = meta@public-inbox.org
	mainrepo = /path/to/meta.git
Diffstat (limited to 'lib/PublicInbox/GitHTTPBackend.pm')
-rw-r--r--lib/PublicInbox/GitHTTPBackend.pm10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/PublicInbox/GitHTTPBackend.pm b/lib/PublicInbox/GitHTTPBackend.pm
index ed8fdf00..d4914795 100644
--- a/lib/PublicInbox/GitHTTPBackend.pm
+++ b/lib/PublicInbox/GitHTTPBackend.pm
@@ -179,7 +179,6 @@ sub prepare_range {
 # returns undef if 403 so it falls back to dumb HTTP
 sub serve_smart {
         my ($env, $git, $path) = @_;
-        my $limiter = $default_limiter;
         my $in = $env->{'psgi.input'};
         my $fd = eval { fileno($in) };
         unless (defined $fd && $fd >= 0) {
@@ -197,7 +196,14 @@ sub serve_smart {
                 my $val = $env->{$name};
                 $env{$name} = $val if defined $val;
         }
-        my $git_dir = ref $git ? $git->{git_dir} : $git;
+        my ($git_dir, $limiter);
+        if (ref $git) {
+                $limiter = $git->{-httpbackend_limiter} || $default_limiter;
+                $git_dir = $git->{git_dir};
+        } else {
+                $limiter = $default_limiter;
+                $git_dir = $git;
+        }
         $env{GIT_HTTP_EXPORT_ALL} = '1';
         $env{PATH_TRANSLATED} = "$git_dir/$path";
         my %rdr = ( 0 => fileno($in) );