Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for not removing idle objects

Before my change, for-loop execute only once.
Let's simplify this part of condition:

(refreshIdle || (count - factory.min)) > toRemove.length

true || NUMBER > toRemove.length
true > toRemove.length

and if toRemove.length = 0
true > 0
true > false  -> true

but if toRemove.length = 1
true > 1
true > true -> false

And examples:
- before http://jsfiddle.net/mBbM7/
- after http://jsfiddle.net/nXWys/1/
  • Loading branch information...
commit 8e50d0a2b9c9e9256e4d67e9ad7950d9d5bf1943 1 parent be063d9
@PiotrWpl PiotrWpl authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/generic-pool.js
View
2  lib/generic-pool.js
@@ -165,7 +165,7 @@ exports.Pool = function (factory) {
// Go through the available (idle) items,
// check if they have timed out
- for (i = 0, al = availableObjects.length; i < al && (refreshIdle || (count - factory.min)) > toRemove.length ; i += 1) {
+ for (i = 0, al = availableObjects.length; i < al && (refreshIdle || (count - factory.min > toRemove.length)); i += 1) {
timeout = availableObjects[i].timeout;
if (now >= timeout) {
// Client timed out, so destroy it.
Please sign in to comment.
Something went wrong with that request. Please try again.