Skip to content

Commit

Permalink
Merge pull request #543 from CartoDB/2.11-remove-ended-connections
Browse files Browse the repository at this point in the history
Remove disconnected clients from the pool
  • Loading branch information
brianc committed Mar 22, 2014
2 parents f15a027 + fb118cf commit b12dd4c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/pool.js
Expand Up @@ -33,10 +33,20 @@ var pools = {
pool.destroy(client);
});

// Remove connection from pool on disconnect
client.on('end', function(e) {
// 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 b12dd4c

Please sign in to comment.