limit the number of player names resolved in one go, to prevent excessive requests

for #656 number 4
This commit is contained in:
Jon Atkins 2013-11-24 01:04:45 +00:00
parent 44ee4c7200
commit 1501f98f9b

View File

@ -66,6 +66,12 @@ window.resolvePlayerNames = function() {
//limit per request. stock site is never more than 13 (8 res, 4 mods, owner) //limit per request. stock site is never more than 13 (8 res, 4 mods, owner)
//testing shows 15 works and 20 fails //testing shows 15 works and 20 fails
var MAX_RESOLVE_PLAYERS_PER_REQUEST = 15; var MAX_RESOLVE_PLAYERS_PER_REQUEST = 15;
var MAX_RESOLVE_REQUESTS = 8;
if (window.playersToResolve.length > MAX_RESOLVE_PLAYERS_PER_REQUEST*MAX_RESOLVE_REQUESTS) {
console.log('Warning: player name resolve queue had '+window.playersToResolve.length+' entries. Limiting to the first '+MAX_RESOLVE_PLAYERS_PER_REQUEST*MAX_RESOLVE_REQUESTS+' to prevent excessive requests');
window.playersToResolve = playersToResolve.slice(0,MAX_RESOLVE_PLAYERS_PER_REQUEST*MAX_RESOLVE_REQUESTS);
}
var p = window.playersToResolve.slice(0,MAX_RESOLVE_PLAYERS_PER_REQUEST); var p = window.playersToResolve.slice(0,MAX_RESOLVE_PLAYERS_PER_REQUEST);
window.playersToResolve = playersToResolve.slice(MAX_RESOLVE_PLAYERS_PER_REQUEST); window.playersToResolve = playersToResolve.slice(MAX_RESOLVE_PLAYERS_PER_REQUEST);