resource pool Close func may not be called
Cas-pian opened this issue · 3 comments
Hi, guys!
There might be a bug, which seem to be ingore some resource without calling Close function in SimpleResourcePool.getIdleHandle
if len(p.idleHandles) > 0 {
p.idleHandles = []*idleHandle{}
}
If goes here, it means there's no handle can be used, but why don't close them, just ingore?
I think it might be this:
if len(p.idleHandles) > 0 {
toClose = p.idleHandles
p.idleHandles = []*idleHandle{}
}
Thanks!
I don't think this is an issue. if the program have reached this condition, then i must be greater or equal to len(p.idleHandles) because of the condition immediately above this. i is transitively greater than 0 because of this conditional block. hence toClose is set correctly 2 conditions above.
Is there some flaw in my reasoning?
o, ic. there's an off by one error. thanks for pointing this out. I'll send out a fix
Thanks for pointing out the error