From 9f0826260d84f3a14996d02fe14ec7bccf904472 Mon Sep 17 00:00:00 2001 From: Dan Mills Date: Thu, 17 Jul 2008 20:40:29 -0700 Subject: [PATCH] time out requests after 30 seconds --- services/sync/modules/dav.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/sync/modules/dav.js b/services/sync/modules/dav.js index 63cee604a1ef..9f04146db946 100644 --- a/services/sync/modules/dav.js +++ b/services/sync/modules/dav.js @@ -133,6 +133,12 @@ DAVCollection.prototype = { request.mozBackgroundRequest = true; request.open(op, this._baseURL + path, true); + // time out requests after 30 seconds + let cb = function() { request.abort(); }; + let listener = new Utils.EventListener(cb); + let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); + timer.initWithCallback(listener, 30000, timer.TYPE_ONE_SHOT); + // Force cache validation let channel = request.channel; channel = channel.QueryInterface(Ci.nsIRequest); @@ -156,7 +162,7 @@ DAVCollection.prototype = { if (ret.status == 423) this._log.warn("_makeRequest: got status " + ret.status + " (This is not necessarily bad. It could just mean that another Firefox was syncing at the same time.)"); else - if (ret.status < 200 || ret.status >= 300) + if (ret.status < 200 || ret.status >= 300) this._log.warn("_makeRequest: got status " + ret.status); self.done(ret);