Skip to content

Commit

Permalink
Image upload was overzealous: 2047 requests per second per image.
Browse files Browse the repository at this point in the history
It was polling for each image once every 100 milliseconds, and had
a loop within a loop which doubled the amount of requests each
time.
  • Loading branch information
gkoberger committed Feb 19, 2011
1 parent 7af7a6c commit 4e01b69
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions media/js/zamboni/devhub.js
Expand Up @@ -1332,7 +1332,7 @@ function initCompatibility() {
function imagePoller() {
this.start = function(override, delay) {
if (override || !this.poll) {
this.poll = window.setTimeout(this.check, delay || 100);
this.poll = window.setTimeout(this.check, delay || 1000);
}
};
this.stop = function() {
Expand Down Expand Up @@ -1364,8 +1364,11 @@ var imageStatus = {
};
this.preview.check = function() {
var self = imageStatus;
$('div.preview-thumb').each(function(e) {
var $this = $(this);
$('div.preview-thumb').each(function(){
check_images(this);
});
function check_images(el) {
var $this = $(el);
if ($this.hasClass('preview-successful')) {
return;
}
Expand All @@ -1379,12 +1382,13 @@ var imageStatus = {
}
};
img.onerror = function() {
self.preview.start(true, 2500);
setTimeout(function(){ check_images(el) }, 2500);
self.polling();
$this.attr('style', '').addClass('preview-error');
delete img;
};
img.src = self.newurl($this.attr('data-url'));
});
}
};
this.icon.start();
this.preview.start();
Expand Down

0 comments on commit 4e01b69

Please sign in to comment.