| |   |
| 44 | 44 | $children_active += 1 |
| 45 | 45 | |
| 46 | 46 | if $children_active - $children_reaped > MAX_CHILDREN |
| 47 | log(Process.pid, "too many active children #{$children_active - $children_reaped}/#{MAX_CHILDREN}") |
| 47 | 48 | session.close |
| 49 | # we didn't actually do the fork, so decrease the count |
| 50 | $children_active -= 1 |
| 48 | 51 | next |
| 49 | 52 | end |
| 50 | 53 | |
| … | … | |
| 60 | 60 | host = $4 |
| 61 | 61 | |
| 62 | 62 | path = "#{BASE_PATH}/#{base_path}" |
| 63 | | if !File.join(File.expand_path(path)).index(BASE_PATH) == 0 || !File.directory?(path) |
| 63 | if !File.join(File.expand_path(path)).index(BASE_PATH) == 0 || !File.directory?(path) |
| 64 | 64 | log(Process.pid, "Invalid path: #{base_path}") |
| 65 | 65 | session.close |
| 66 | $children_active -= 1 |
| 66 | 67 | next |
| 67 | 68 | end |
| 68 | 69 | |
| 69 | 70 | if !File.exist?(File.join(path, "git-daemon-export-ok")) |
| 70 | 71 | session.close |
| 72 | $children_active -= 1 |
| 71 | 73 | next |
| 72 | 74 | end |
| 73 | 75 | |
| … | … | |
| 92 | 92 | session.close |
| 93 | 93 | |
| 94 | 94 | if repository |
| 95 | | if ip_family == "AF_INET6" |
| 96 | | repository.cloned_from(ip) |
| 97 | | else |
| 98 | | localization = @geoip.country(ip) |
| 99 | | repository.cloned_from(ip, localization[3], localization[5]) |
| 100 | | end |
| 95 | if ip_family == "AF_INET6" |
| 96 | repository.cloned_from(ip) |
| 97 | else |
| 98 | localization = @geoip.country(ip) |
| 99 | repository.cloned_from(ip, localization[3], localization[5]) |
| 100 | end |
| 101 | 101 | else |
| 102 | 102 | log(pid, "Cannot find repository: #{path}") |
| 103 | 103 | end |
| 104 | 104 | |
| 105 | 105 | exec(cmd) |
| 106 | | |
| 106 | $children_reaped += 1 |
| 107 | 107 | exit! |
| 108 | 108 | end |
| 109 | 109 | end |
| toggle raw diff |
--- a/script/git-daemon
+++ b/script/git-daemon
@@ -44,7 +44,10 @@ class Daemon
$children_active += 1
if $children_active - $children_reaped > MAX_CHILDREN
+ log(Process.pid, "too many active children #{$children_active - $children_reaped}/#{MAX_CHILDREN}")
session.close
+ # we didn't actually do the fork, so decrease the count
+ $children_active -= 1
next
end
@@ -57,14 +60,16 @@ class Daemon
host = $4
path = "#{BASE_PATH}/#{base_path}"
- if !File.join(File.expand_path(path)).index(BASE_PATH) == 0 || !File.directory?(path)
+ if !File.join(File.expand_path(path)).index(BASE_PATH) == 0 || !File.directory?(path)
log(Process.pid, "Invalid path: #{base_path}")
session.close
+ $children_active -= 1
next
end
if !File.exist?(File.join(path, "git-daemon-export-ok"))
session.close
+ $children_active -= 1
next
end
@@ -87,18 +92,18 @@ class Daemon
session.close
if repository
- if ip_family == "AF_INET6"
- repository.cloned_from(ip)
- else
- localization = @geoip.country(ip)
- repository.cloned_from(ip, localization[3], localization[5])
- end
+ if ip_family == "AF_INET6"
+ repository.cloned_from(ip)
+ else
+ localization = @geoip.country(ip)
+ repository.cloned_from(ip, localization[3], localization[5])
+ end
else
log(pid, "Cannot find repository: #{path}")
end
exec(cmd)
-
+ $children_reaped += 1
exit!
end
end |