summaryrefslogtreecommitdiff
path: root/git-daemon
diff options
context:
space:
mode:
authorTony Finch <dot@dotat.at>2010-03-26 18:23:24 +0000
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>2010-05-22 15:54:40 +0100
commitf14a8627786893cf1f94f31e890f579d1e1d75fb (patch)
tree8c40c6181796b5dec541ab6a9f08e9057120582f /git-daemon
parentabb80356bb59bcc101a57949badbb85fde4db9ba (diff)
downloaduserv-utils-f14a8627786893cf1f94f31e890f579d1e1d75fb.tar.gz
git-daemon: Log timeout errors and polish code a bit.
Diffstat (limited to 'git-daemon')
-rwxr-xr-xgit-daemon/git-daemon.pl8
1 files changed, 2 insertions, 6 deletions
diff --git a/git-daemon/git-daemon.pl b/git-daemon/git-daemon.pl
index 4f8a774..aabef66 100755
--- 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 = "";
- # 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;
@@ -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 $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\""
@@ -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;
-
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: $!";