summaryrefslogtreecommitdiffstats
path: root/script/git-daemon
diff options
context:
space:
mode:
authorJohan Sørensen <johan@johansorensen.com>2009-02-04 10:17:04 +0100
committerJohan Sørensen <johan@johansorensen.com>2009-02-04 10:17:04 +0100
commit2efb027bf7c9e8f3a5fc27334890f2c0f225699b (patch)
treea15c4ab4740e957c15e36fae018551dda23d49e1 /script/git-daemon
parent92bb70a143de0ca8987ab7ce07a0a143ad42d8d6 (diff)
downloadgitorious-mainline-outdated-2efb027bf7c9e8f3a5fc27334890f2c0f225699b.zip
gitorious-mainline-outdated-2efb027bf7c9e8f3a5fc27334890f2c0f225699b.tar.gz
gitorious-mainline-outdated-2efb027bf7c9e8f3a5fc27334890f2c0f225699b.tar.bz2
Moved the connection to Repository outside the fork in git-daemon
Diffstat (limited to 'script/git-daemon')
-rwxr-xr-xscript/git-daemon43
1 files changed, 20 insertions, 23 deletions
diff --git a/script/git-daemon b/script/git-daemon
index 65966c1..a905e0a 100755
--- a/script/git-daemon
+++ b/script/git-daemon
@@ -84,34 +84,31 @@ module Git
$children_active -= 1
return
end
+
+ begin
+ repository = ::Repository.find_by_path(path)
+ log(Process.pid, "Connection from #{ip} for #{path.inspect}")
+
+ if repository
+ if ip_family == "AF_INET6"
+ repository.cloned_from(ip)
+ else
+ geoip = GeoIP.new(File.join(RAILS_ROOT, "data", "GeoIP.dat"))
+ localization = geoip.country(ip)
+ repository.cloned_from(ip, localization[3], localization[5])
+ end
+ else
+ log(Process.pid, "Cannot find repository: #{path}")
+ end
+ rescue => e
+ log(Process.pid, "AR error: #{e.class.name} #{e.message}:\n #{e.backtrace.join("\n ")}")
+ end
+
Dir.chdir(path) do
cmd = "git-upload-pack --strict --timeout=#{TIMEOUT} ."
child_pid = fork do
- repository = nil
-
- begin
- repository = ::Repository.find_by_path(path)
- rescue => e
- log(Process.pid, "AR error: #{e.class.name} #{e.message}:\n #{e.backtrace.join("\n ")}")
- end
-
- pid = Process.pid
- log(pid, "Connection from #{ip} for #{path.inspect}")
-
- if repository
- if ip_family == "AF_INET6"
- repository.cloned_from(ip)
- else
- geoip = GeoIP.new(File.join(RAILS_ROOT, "data", "GeoIP.dat"))
- localization = geoip.country(ip)
- repository.cloned_from(ip, localization[3], localization[5])
- end
- else
- log(pid, "Cannot find repository: #{path}")
- end
-
log(Process.pid, "Deferred in #{'%0.5f' % (Time.now - start_time)}s")
$stdout.reopen(session)