coopernurse/node-pool — Issue #29: me.destroy() not destroying
Author: JoeZ99
Created: 2012-01-26 16:32:11+00:00
State: open

I don't know if I'm missing something, but in the code, me.destroy() is as follows:

https://github.com/coopernurse/node-pool/blob/master/lib/generic-pool.js#L114
```
me.destroy = function(obj) {
count -= 1;
factory.destroy(obj);
};
```

and, looking at the possible scenarios:

* If the connection that is going to be destroyed it's available, then it's on *availableObjects* array, which is an array of objects of the form `{obj:obj, timeout:timeout_in_ml}`, just disconnecting the object (which is what the custom defined 'destroy' function at the constructor is meant for) won't remove the element `{obj:obj, timeout:timeout_in_ms}` from the *availableObjects* array, thus that item will still be available, but the object it returns won't be working anymore!.
* If the connection that is going to be destroyed it's "in use", it should also be released (or that could be left in the hands of the user, I don't know).

I guess when destroying the conn, the 'availableObjects' corresponding item should be shifted, too.

Please, let me know if I'm missing something. I've read the code a zillion times and can't find how it can be otherwise than what I just said.

txs