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