diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2006-01-12 22:52:49 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2006-01-12 22:52:49 +0000 |
commit | d4ad3657e44dcf2feb26e755ad7dcd6dbeaa5d09 (patch) | |
tree | 6ad45ec8629fdb626c44ab34fdcf5946e6d1ec37 /misc | |
parent | cccca3b17e3bd409c6325029c650294c8722c7d1 (diff) | |
download | brdo-d4ad3657e44dcf2feb26e755ad7dcd6dbeaa5d09.tar.gz brdo-d4ad3657e44dcf2feb26e755ad7dcd6dbeaa5d09.tar.bz2 |
- #44299: Avoid possible race condition with 0-delay progressbar monitoring
Diffstat (limited to 'misc')
-rw-r--r-- | misc/progress.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/misc/progress.js b/misc/progress.js index e7c289e31..940c32713 100644 --- a/misc/progress.js +++ b/misc/progress.js @@ -60,6 +60,8 @@ progressBar.prototype.startMonitoring = function (uri, delay) { */ progressBar.prototype.stopMonitoring = function () { clearTimeout(this.timer); + // This allows monitoring to be stopped from within the callback + this.uri = null; } /** @@ -69,7 +71,9 @@ progressBar.prototype.sendPing = function () { if (this.timer) { clearTimeout(this.timer); } - this.method(this.uri, this.receivePing, this, ''); + if (this.uri) { + this.method(this.uri, this.receivePing, this, ''); + } } /** @@ -82,8 +86,10 @@ progressBar.prototype.receivePing = function (string, xmlhttp, pb) { } // Split into values var matches = string.length > 0 ? string.split('|') : []; - pb.timer = setTimeout(function() { pb.sendPing(); }, pb.delay); + // Update progress if (matches.length >= 2) { pb.setProgress(matches[0], matches[1]); } + // Schedule next timer + pb.timer = setTimeout(function() { pb.sendPing(); }, pb.delay); } |