added try-finally guards to JSONP calls
This commit is contained in:
parent
25ec6105c5
commit
350cacb2f3
@ -42,25 +42,29 @@ OSRM.JSONP = {
|
|||||||
|
|
||||||
// wrap timeout function
|
// wrap timeout function
|
||||||
OSRM.JSONP.timeouts[id] = function(response) {
|
OSRM.JSONP.timeouts[id] = function(response) {
|
||||||
timeout_function(response);
|
try {
|
||||||
|
timeout_function(response);
|
||||||
OSRM.JSONP.callbacks[id] = OSRM.JSONP.late; // clean functions
|
} finally {
|
||||||
OSRM.JSONP.timeouts[id] = OSRM.JSONP.late;
|
OSRM.JSONP.callbacks[id] = OSRM.JSONP.late; // clean functions
|
||||||
OSRM.JSONP.fences[id] = undefined; // clean fence
|
OSRM.JSONP.timeouts[id] = OSRM.JSONP.empty;
|
||||||
|
OSRM.JSONP.fences[id] = undefined; // clean fence
|
||||||
|
}
|
||||||
|
|
||||||
// OSRM.debug.log("[jsonp] timout handling: "+id);
|
// OSRM.debug.log("[jsonp] timout handling: "+id);
|
||||||
};
|
};
|
||||||
|
|
||||||
// wrap callback function
|
// wrap callback function
|
||||||
OSRM.JSONP.callbacks[id] = function(response) {
|
OSRM.JSONP.callbacks[id] = function(response) {
|
||||||
clearTimeout(OSRM.JSONP.timers[id]); // clear timeout timer
|
clearTimeout(OSRM.JSONP.timers[id]); // clear timeout timer
|
||||||
OSRM.JSONP.timers[id] = undefined;
|
OSRM.JSONP.timers[id] = undefined;
|
||||||
|
|
||||||
callback_function(response); // actual wrapped callback
|
try {
|
||||||
|
callback_function(response); // actual wrapped callback
|
||||||
OSRM.JSONP.callbacks[id] = OSRM.JSONP.late; // clean functions
|
} finally {
|
||||||
OSRM.JSONP.timeouts[id] = OSRM.JSONP.late;
|
OSRM.JSONP.callbacks[id] = OSRM.JSONP.empty; // clean functions
|
||||||
OSRM.JSONP.fences[id] = undefined; // clean fence
|
OSRM.JSONP.timeouts[id] = OSRM.JSONP.late;
|
||||||
|
OSRM.JSONP.fences[id] = undefined; // clean fence
|
||||||
|
}
|
||||||
|
|
||||||
// OSRM.debug.log("[jsonp] response handling: "+id);
|
// OSRM.debug.log("[jsonp] response handling: "+id);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user