From 350cacb2f3ad97aac9d99217d0bcca058cb1ff51 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Sun, 18 Mar 2012 11:38:21 +0100 Subject: [PATCH] added try-finally guards to JSONP calls --- WebContent/OSRM.JSONP.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/WebContent/OSRM.JSONP.js b/WebContent/OSRM.JSONP.js index 9bc32e4a5..00954e083 100644 --- a/WebContent/OSRM.JSONP.js +++ b/WebContent/OSRM.JSONP.js @@ -42,25 +42,29 @@ OSRM.JSONP = { // wrap timeout function OSRM.JSONP.timeouts[id] = function(response) { - timeout_function(response); - - OSRM.JSONP.callbacks[id] = OSRM.JSONP.late; // clean functions - OSRM.JSONP.timeouts[id] = OSRM.JSONP.late; - OSRM.JSONP.fences[id] = undefined; // clean fence + try { + timeout_function(response); + } finally { + OSRM.JSONP.callbacks[id] = OSRM.JSONP.late; // clean functions + OSRM.JSONP.timeouts[id] = OSRM.JSONP.empty; + OSRM.JSONP.fences[id] = undefined; // clean fence + } // OSRM.debug.log("[jsonp] timout handling: "+id); }; // wrap callback function 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; - callback_function(response); // actual wrapped callback - - OSRM.JSONP.callbacks[id] = OSRM.JSONP.late; // clean functions - OSRM.JSONP.timeouts[id] = OSRM.JSONP.late; - OSRM.JSONP.fences[id] = undefined; // clean fence + try { + callback_function(response); // actual wrapped callback + } finally { + OSRM.JSONP.callbacks[id] = OSRM.JSONP.empty; // clean functions + OSRM.JSONP.timeouts[id] = OSRM.JSONP.late; + OSRM.JSONP.fences[id] = undefined; // clean fence + } // OSRM.debug.log("[jsonp] response handling: "+id); };