File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ func TestPool(t *testing.T) {
216
216
disconnectDone := make (chan struct {})
217
217
_ , err = p .get (context .Background ())
218
218
noerr (t , err )
219
- getCtx , getCancel := context .WithCancel (context .Background ())
219
+ getCtx , getCancel := context .WithTimeout (context .Background (), 30 * time . Second )
220
220
defer getCancel ()
221
221
go func () {
222
222
defer close (getDone )
@@ -226,20 +226,23 @@ func TestPool(t *testing.T) {
226
226
return
227
227
default :
228
228
loopCtx , loopCancel := context .WithTimeout (getCtx , 3 * time .Second )
229
- _ , _ = p .get (loopCtx )
229
+ c , err : = p .get (loopCtx )
230
230
loopCancel ()
231
+ if err == nil {
232
+ _ = p .put (c )
233
+ }
231
234
time .Sleep (time .Microsecond )
232
235
}
233
236
}
234
237
}()
235
238
go func () {
239
+ defer close (disconnectDone )
236
240
_ , err := p .get (getCtx )
237
241
noerr (t , err )
238
242
ctx , cancel := context .WithTimeout (context .Background (), 3 * time .Microsecond )
239
243
defer cancel ()
240
244
err = p .disconnect (ctx )
241
245
noerr (t , err )
242
- close (disconnectDone )
243
246
}()
244
247
<- getDone
245
248
close (cleanup )
You can’t perform that action at this time.
0 commit comments