Retry w/ JSON to avoid cross-object contamination

This commit is contained in:
Artur Adib 2012-04-04 18:25:22 -04:00
parent 921c1e82a3
commit bdc8a91778

View File

@ -248,16 +248,21 @@ function done() {
}
}
function sendTaskResult(snapshot, task, failure) {
var result = { browser: browser,
id: task.id,
numPages: task.pdfDoc ?
(task.pageLimit || task.pdfDoc.numPages) : 0,
failure: failure,
file: task.file,
round: task.round,
page: task.pageNum,
snapshot: snapshot };
function sendTaskResult(snapshot, task, failure, result) {
// Optional result argument is for retrying XHR requests - see below
if (!result) {
result = JSON.stringify({
browser: browser,
id: task.id,
numPages: task.pdfDoc ?
(task.pageLimit || task.pdfDoc.numPages) : 0,
failure: failure,
file: task.file,
round: task.round,
page: task.pageNum,
snapshot: snapshot
});
}
var r = new XMLHttpRequest();
// (The POST URI is ignored atm.)
@ -268,11 +273,11 @@ function sendTaskResult(snapshot, task, failure) {
inFlightRequests--;
// Retry until successful
if (r.status !== 200)
sendTaskResult(snapshot, task, failure);
sendTaskResult(null, null, null, result);
}
};
document.getElementById('inFlightCount').innerHTML = inFlightRequests++;
r.send(JSON.stringify(result));
r.send(result);
}
function clear(ctx) {