* VRFS-2110 - add simple guard to protect against xtra callbacks

This commit is contained in:
Seth Call 2014-08-31 15:02:49 -05:00
parent c35cfcf0f9
commit e503287400
1 changed files with 26 additions and 1 deletions

View File

@ -365,6 +365,11 @@
}
}
// we know we are attempting a pass if the backend or prime guard timeout is not null
function isAttemptingPass() {
backendGuardTimeout != null || primePumpTimeout != null;
}
function clearPrimeGuard() {
if (primeGuardTimeout) {
clearTimeout(primeGuardTimeout);
@ -375,6 +380,7 @@
function setPrimeGuard() {
clearPrimeGuard();
primeGuardTimeout = setTimeout(function () {
clearPrimeGuard();
primeTimedOut()
}, (PRIME_PUMP_TIME + 10) * 1000);
}
@ -382,6 +388,7 @@
function setBackendGuard() {
clearBackendGuard();
backendGuardTimeout = setTimeout(function () {
clearBackendGuard();
backendTimedOut()
}, (gon.ftue_network_test_duration + 1) * 1000);
}
@ -550,6 +557,10 @@
}
function primePumpTimeout(data) {
if(!isAttemptingPass()) {
logger.error("primePumpTimeout: already completed the test pass. indicates backend sent > 1 final event");
return;
}
clearPrimeGuard();
scoring = false;
logger.debug("the prime pump routine timed out")
@ -557,6 +568,11 @@
}
function primePumpComplete(data) {
if(!isAttemptingPass()) {
logger.error("primePumpComplete: already completed the test pass. indicates backend sent > 1 final event");
return;
}
if (data.progress === true) {
// waiting...
logger.debug("pump prime progress report");
@ -576,6 +592,11 @@
}
function networkTestComplete(data) {
if(!isAttemptingPass()) {
logger.error("networkTestComplete: already completed the test pass. indicates backend sent > 1 final event");
return;
}
var attempt = getCurrentAttempt();
function refineTest(up) {
@ -708,6 +729,11 @@
}
function networkTestTimeout(data) {
if(!isAttemptingPass()) {
logger.error("networkTestTimeout: already completed the test pass. indicates backend sent > 1 final event");
return;
}
clearBackendGuard();
logger.warn("network timeout when testing latency test: " + data);
@ -729,7 +755,6 @@
else {
$startNetworkTestBtn.text('START NETWORK TEST').removeClass('button-grey').addClass('button-orange');
}
}
function initializeNextButtonState() {