Skip to content

Commit

Permalink
Avoid loop between pool.destroy and client.end
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Santilli committed Mar 18, 2014
1 parent 9c5cd8d commit fb118cf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/pool.js
Expand Up @@ -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();
}
});
Expand Down

0 comments on commit fb118cf

Please sign in to comment.