Skip to content

Commit b12dd4c

Browse files
committed
Merge pull request #543 from CartoDB/2.11-remove-ended-connections
Remove disconnected clients from the pool
2 parents f15a027 + fb118cf commit b12dd4c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/pool.js

+10
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,20 @@ var pools = {
3333
pool.destroy(client);
3434
});
3535

36+
// Remove connection from pool on disconnect
37+
client.on('end', function(e) {
38+
// Do not enter infinite loop between pool.destroy
39+
// and client 'end' event...
40+
if ( ! client._destroying ) {
41+
pool.destroy(client);
42+
}
43+
});
44+
3645
return cb(null, client);
3746
});
3847
},
3948
destroy: function(client) {
49+
client._destroying = true;
4050
client.end();
4151
}
4252
});

0 commit comments

Comments
 (0)