diff --git a/lib/pool.js b/lib/pool.js index 02e7ddbb5..887a0e4ed 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -35,13 +35,18 @@ var pools = { // Remove connection from pool on disconnect client.on('end', function(e) { - pool.destroy(client); + // Do not enter infinite loop between pool.destroy + // and client 'end' event... + if ( ! client._destroying ) { + pool.destroy(client); + } }); return cb(null, client); }); }, destroy: function(client) { + client._destroying = true; client.end(); } });