xmlhttp sometimes get stuck in main loop: workaround

This commit is contained in:
Andrew Dolgov 2006-03-02 18:07:46 +01:00
parent f26ef034b5
commit c441662f98
1 changed files with 13 additions and 0 deletions

View File

@ -8,6 +8,7 @@ var current_subtitle = "";
var daemon_enabled = false; var daemon_enabled = false;
var _qfd_deleted_feed = 0; var _qfd_deleted_feed = 0;
var firsttime_update = true; var firsttime_update = true;
var last_refetch = 0;
/*@cc_on @*/ /*@cc_on @*/
/*@if (@_jscript_version >= 5) /*@if (@_jscript_version >= 5)
@ -102,6 +103,10 @@ function refetch_callback() {
if (xmlhttp.readyState == 4) { if (xmlhttp.readyState == 4) {
try { try {
var date = new Date();
last_refetch = date.getTime() / 1000;
if (!xmlhttp.responseXML) { if (!xmlhttp.responseXML) {
notify("refetch_callback: backend did not return valid XML"); notify("refetch_callback: backend did not return valid XML");
return; return;
@ -207,11 +212,19 @@ function scheduleFeedUpdate(force) {
debug("in scheduleFeedUpdate"); debug("in scheduleFeedUpdate");
var date = new Date();
if (!xmlhttp_ready(xmlhttp) && last_refetch < date.getTime() / 1000 - 60) {
debug("xmlhttp seems to be stuck, aborting");
xmlhttp.abort();
}
if (xmlhttp_ready(xmlhttp)) { if (xmlhttp_ready(xmlhttp)) {
xmlhttp.open("GET", query_str, true); xmlhttp.open("GET", query_str, true);
xmlhttp.onreadystatechange=refetch_callback; xmlhttp.onreadystatechange=refetch_callback;
xmlhttp.send(null); xmlhttp.send(null);
} else { } else {
debug("xmlhttp busy");
printLockingError(); printLockingError();
} }
} }