File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -149,9 +149,14 @@ def connect *args
149
149
ssl_client . close
150
150
end
151
151
152
- it "should not leave dangling connections after garbage collection" do
152
+ def run_gc
153
153
GC . start
154
- sleep 0.300 # Let GC do its work
154
+ sleep ( 1 ) if defined? ( Rubinius ) # Let the Rubinius GC thread do its work
155
+ end
156
+
157
+ it "should not leave dangling connections after garbage collection" do
158
+ run_gc
159
+
155
160
client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] )
156
161
before_count = client . query ( "SHOW STATUS LIKE 'Threads_connected'" ) . first [ 'Value' ] . to_i
157
162
@@ -161,23 +166,20 @@ def connect *args
161
166
after_count = client . query ( "SHOW STATUS LIKE 'Threads_connected'" ) . first [ 'Value' ] . to_i
162
167
after_count . should == before_count + 10
163
168
164
- GC . start
165
- sleep 0.300 # Let GC do its work
169
+ run_gc
166
170
final_count = client . query ( "SHOW STATUS LIKE 'Threads_connected'" ) . first [ 'Value' ] . to_i
167
171
final_count . should == before_count
168
172
end
169
173
170
174
if Process . respond_to? ( :fork )
171
175
it "should not close connections when running in a child process" do
172
- GC . start
173
- sleep 1 if defined? Rubinius # Let the rbx GC thread do its work
176
+ run_gc
174
177
client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] )
175
178
176
179
fork do
177
180
client . query ( 'SELECT 1' )
178
181
client = nil
179
- GC . start
180
- sleep 1 if defined? Rubinius # Let the rbx GC thread do its work
182
+ run_gc
181
183
end
182
184
183
185
Process . wait
You can’t perform that action at this time.
0 commit comments