chiark
/
gitweb
/
~mdw
/
userv-utils
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
abb8035
)
git-daemon: Log timeout errors and polish code a bit.
author
Tony Finch
<dot@dotat.at>
Fri, 26 Mar 2010 18:23:24 +0000
(18:23 +0000)
committer
Ian Jackson
<ian@liberator.relativity.greenend.org.uk>
Sat, 22 May 2010 14:54:40 +0000
(15:54 +0100)
git-daemon/git-daemon.pl
patch
|
blob
|
blame
|
history
diff --git
a/git-daemon/git-daemon.pl
b/git-daemon/git-daemon.pl
index 4f8a7747cb72aa24d96023dffc8a8e65698eeb91..aabef66a6cb7d1692fd7a7d3f38004b8c54746b5 100755
(executable)
--- a/
git-daemon/git-daemon.pl
+++ b/
git-daemon/git-daemon.pl
@@
-44,7
+44,7
@@
sub fail {
sub xread {
my $length = shift;
my $buffer = "";
sub xread {
my $length = shift;
my $buffer = "";
- # simply die if the client takes too long
+ local $SIG{ALRM} = sub { fail "timeout" };
alarm 30;
while ($length > length $buffer) {
my $ret = sysread STDIN, $buffer, $length, length $buffer;
alarm 30;
while ($length > length $buffer) {
my $ret = sysread STDIN, $buffer, $length, length $buffer;
@@
-59,9
+59,7
@@
sub xread {
my $len_hex = xread 4;
fail "non-hexadecimal packet length" unless $len_hex =~ m{^[0-9a-zA-Z]{4}$};
my $len_hex = xread 4;
fail "non-hexadecimal packet length" unless $len_hex =~ m{^[0-9a-zA-Z]{4}$};
-my $len = hex $len_hex;
-
-my $line = xread $len;
+my $line = xread hex $len_hex;
unless ($line =~ m{^git-upload-pack (?:~($TILDE)/)?($REPO[.]git)\0host=($HOSTNAME)\0$}) {
$line =~ s/[^ -~]+/ /g;
fail "could not parse \"$line\""
unless ($line =~ m{^git-upload-pack (?:~($TILDE)/)?($REPO[.]git)\0host=($HOSTNAME)\0$}) {
$line =~ s/[^ -~]+/ /g;
fail "could not parse \"$line\""
@@
-71,12
+69,10
@@
my $url = $tilde ? "git://$host/~$tilde/$repo" : "git://$host/$repo";
my $user = $vhost_user_from_tilde{$host} ? $tilde : $vhost_default_user{$host};
fail "no user configuration for $url" unless defined $user;
my $user = $vhost_user_from_tilde{$host} ? $tilde : $vhost_default_user{$host};
fail "no user configuration for $url" unless defined $user;
-
syslog 'info', "$peer $user $url";
my @opts = ("-DCLIENT=$addr", "-DHOST=$host", "-DREPO=$repo");
push @opts, "-DTILDE=$tilde" if defined $tilde;
syslog 'info', "$peer $user $url";
my @opts = ("-DCLIENT=$addr", "-DHOST=$host", "-DREPO=$repo");
push @opts, "-DTILDE=$tilde" if defined $tilde;
-
exec 'userv', @opts, $user, 'git-upload-pack'
or fail "exec userv: $!";
exec 'userv', @opts, $user, 'git-upload-pack'
or fail "exec userv: $!";