From fb118cf069ede16bfe0f2e29556538a6ed8b6b38 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Tue, 18 Mar 2014 09:42:19 +0100 Subject: [PATCH] Avoid loop between pool.destroy and client.end --- lib/pool.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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(); } });