diff --git a/pool.js b/pool.js index 2c1ba6b..ddfae6c 100644 --- a/pool.js +++ b/pool.js @@ -241,10 +241,13 @@ Pool.prototype = { // will also be called. This should be called within an acquire() // block as an alternative to release(). destroy: function(obj) { - this.count -= 1; this.availableObjects = this.availableObjects.filter(function(objWithTimeout) { - return (objWithTimeout.obj !== obj); - }); + if (objWithTimeout.obj === obj) { + this.count -= 1; + return false; + } + return true; + }.bind(this)); this.destroyHandler(obj); this.ensureMinimum(); },