Description:
fixed too many open file error
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r96:efe2fae6056b - - 1 file changed: 2 inserted, 0 deleted
@@ -48,24 +48,25 | |||
|
48 | 48 | if counter == 0 |
|
49 | 49 | if block_given? |
|
50 | 50 | yield |
|
51 | 51 | end |
|
52 | 52 | end |
|
53 | 53 | |
|
54 | 54 | rescue |
|
55 | 55 | raise |
|
56 | 56 | |
|
57 | 57 | ensure |
|
58 | 58 | # make sure it unlock the directory |
|
59 | 59 | dir.flock(File::LOCK_UN) |
|
60 | + dir.close | |
|
60 | 61 | end |
|
61 | 62 | end |
|
62 | 63 | |
|
63 | 64 | # Check if I am the last one using the dir. If true, call block. |
|
64 | 65 | |
|
65 | 66 | def teardown |
|
66 | 67 | dir = File.new(@dir_name) |
|
67 | 68 | dir.flock(File::LOCK_EX) |
|
68 | 69 | begin |
|
69 | 70 | counter_filename = get_counter_filename |
|
70 | 71 | if File.exist? counter_filename |
|
71 | 72 | # someone is here |
@@ -85,23 +86,24 | |||
|
85 | 86 | end |
|
86 | 87 | else |
|
87 | 88 | # This is BAD |
|
88 | 89 | raise "Error: reference count missing" |
|
89 | 90 | end |
|
90 | 91 | |
|
91 | 92 | rescue |
|
92 | 93 | raise |
|
93 | 94 | |
|
94 | 95 | ensure |
|
95 | 96 | # make sure it unlock the directory |
|
96 | 97 | dir.flock(File::LOCK_UN) |
|
98 | + dir.close | |
|
97 | 99 | end |
|
98 | 100 | end |
|
99 | 101 | |
|
100 | 102 | protected |
|
101 | 103 | |
|
102 | 104 | def get_counter_filename |
|
103 | 105 | return File.join(@dir_name,@usage_filename) |
|
104 | 106 | end |
|
105 | 107 | |
|
106 | 108 | end |
|
107 | 109 | end |
You need to be logged in to leave comments.
Login now