Commit 4d37329c732b394dd521a6568be6b7a5b4c3bd68
1 parent
ef2bf152
Exists in
master
and in
4 other branches
Must ensure that the lock is always removed.
Showing
1 changed file
with
8 additions
and
5 deletions
Show diff stats
lib/gitosis.rb
@@ -27,13 +27,16 @@ class Gitosis | @@ -27,13 +27,16 @@ class Gitosis | ||
27 | def configure | 27 | def configure |
28 | status = Timeout::timeout(20) do | 28 | status = Timeout::timeout(20) do |
29 | File.open(File.join(Dir.tmpdir,"gitlabhq-gitosis.lock"), "w+") do |f| | 29 | File.open(File.join(Dir.tmpdir,"gitlabhq-gitosis.lock"), "w+") do |f| |
30 | - f.flock(File::LOCK_EX) | 30 | + begin |
31 | + f.flock(File::LOCK_EX) | ||
31 | 32 | ||
32 | - pull | ||
33 | - yield(self) | ||
34 | - push | 33 | + pull |
34 | + yield(self) | ||
35 | + push | ||
35 | 36 | ||
36 | - f.flock(File::LOCK_UN) | 37 | + ensure |
38 | + f.flock(File::LOCK_UN) | ||
39 | + end | ||
37 | end | 40 | end |
38 | end | 41 | end |
39 | rescue Exception => ex | 42 | rescue Exception => ex |