From f14a8627786893cf1f94f31e890f579d1e1d75fb Mon Sep 17 00:00:00 2001 From: Tony Finch Date: Fri, 26 Mar 2010 18:23:24 +0000 Subject: [PATCH] git-daemon: Log timeout errors and polish code a bit. --- git-daemon/git-daemon.pl | 8 ++------ 1 file 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: $!"; -- 2.30.2