Skip to content

Commit edba02c

Browse files
author
Sandro Santilli
committed
Remove disconnected clients from the pool
Might fix brianc#458 Fixes CartoDB/CartoDB-SQL-API#135 Avoids loop between pool.destroy and client.end
1 parent bf258e8 commit edba02c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: 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)