# HG changeset patch # User Vladimir Shabanov # Date 1337193995 -14400 # Node ID 22858505bb2d0b5bd831b6ace787adb3b00e9b23 # Parent a6eab6820b374cda0b829e85ab5c42dc13d67b19 Allow RPC and run it synchronously in onunload event. diff -r a6eab6820b37 -r 22858505bb2d lib/js/urweb.js --- a/lib/js/urweb.js Sun May 13 17:41:21 2012 -0400 +++ b/lib/js/urweb.js Wed May 16 22:46:35 2012 +0400 @@ -1184,17 +1184,12 @@ var unloading = false, inFlight = null; function unload() { - unloading = true; - for (; inFlight; inFlight = inFlight.next) { inFlight.data.abort(); } } function requestUri(xhr, uri, needsSig, isRpc) { - if (unloading) - return; - var extraData = null; if (isRpc && uri.length > 2000) { @@ -1202,7 +1197,7 @@ uri = uri.substring(0, 2000); } - xhr.open("POST", uri, true); + xhr.open("POST", uri, !unloading); xhr.setRequestHeader("Content-type", "text/plain"); try { xhr.setRequestHeader("Content-length", "0"); diff -r a6eab6820b37 -r 22858505bb2d src/c/urweb.c --- a/src/c/urweb.c Sun May 13 17:41:21 2012 -0400 +++ b/src/c/urweb.c Wed May 16 22:46:35 2012 +0400 @@ -1336,8 +1336,8 @@ if (ctx->script_header[0] == 0) return ""; else { - char *r = uw_malloc(ctx, 22 + strlen(s)); - sprintf(r, " onunload='unload();%s'", s); + char *r = uw_malloc(ctx, 37 + strlen(s)); + sprintf(r, " onunload='unloading=true;%s;unload()'", s); return r; } }