our $RDTIMEO = 60_000; # milliseconds
our $async_warn; # true in read-only daemons
-use constant MAX_INFLIGHT => (POSIX::PIPE_BUF * 3) /
- 65; # SHA-256 hex size + "\n" in preparation for git using non-SHA1
+# 512: POSIX PIPE_BUF minimum (see pipe(7))
+# 3: @$inflight is flattened [ $OID, $cb, $arg ]
+# 65: SHA-256 hex size + "\n" in preparation for git using non-SHA1
+use constant MAX_INFLIGHT => 512 * 3 / 65;
my %GIT_ESC = (
a => "\a",
scalar(@{$self->{inflight} // []}));
local $in_cleanup = 1;
delete $self->{async_cat};
+ delete $self->{async_chk};
async_wait_all($self);
delete $self->{inflight};
delete $self->{inflight_c};
sub local_nick ($) {
# don't show full FS path, basename should be OK:
- $_[0]->{git_dir} =~ m!/([^/]+?)(?:/*\.git/*)?\z! ? "$1.git" : '???';
+ $_[0]->{nick} // ($_[0]->{git_dir} =~ m!/([^/]+?)(?:/*\.git/*)?\z! ?
+ "$1.git" : undef);
}
sub host_prefix_url ($$) {
"$scheme://$host_port". ($env->{SCRIPT_NAME} || '/') . $url;
}
+sub base_url { # for coderepos, PSGI-only
+ my ($self, $env) = @_; # env - PSGI env
+ my $url = host_prefix_url($env, '');
+ # for mount in Plack::Builder
+ $url .= '/' if substr($url, -1, 1) ne '/';
+ $url . $self->{nick} . '/';
+}
+
+sub isrch {} # TODO
+
sub pub_urls {
my ($self, $env) = @_;
if (my $urls = $self->{cgit_url}) {
return map { host_prefix_url($env, $_) } @$urls;
}
- (local_nick($self));
+ (local_nick($self) // '???');
}
sub cat_async_begin {
}
sub cloneurl {
- my ($self) = @_;
+ my ($self, $env) = @_;
$self->{cloneurl} // do {
my @urls = split(/\s+/s, try_cat("$self->{git_dir}/cloneurl"));
scalar(@urls) ? ($self->{cloneurl} = \@urls) : undef;
- } // [];
+ } // [ substr(base_url($self, $env), 0, -1) ];
}
# for grokmirror, which doesn't read gitweb.description