aboutsummaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorDavid Barksdale <amatus@amatus.name>2014-07-08 18:28:01 -0500
committerDavid Barksdale <amatus@amatus.name>2014-07-08 18:28:01 -0500
commit69b5048237de8a9ae99cc1c4f145e3af197ced9d (patch)
treee454506b0c2bb81843f34914102ba0576e90e029 /src/js
parentaa77c7f904034b19500b4926527d306f080c0a95 (diff)
Block execution of main until after window connect
Diffstat (limited to 'src/js')
-rw-r--r--src/js/pre.js17
-rw-r--r--src/js/program.js4
-rw-r--r--src/js/service.js4
3 files changed, 4 insertions, 21 deletions
diff --git a/src/js/pre.js b/src/js/pre.js
index 35321f9..5735936 100644
--- a/src/js/pre.js
+++ b/src/js/pre.js
@@ -74,21 +74,11 @@ gnunet_prerun = function() {
sync_callback();
}
}
+ addRunDependency('window-init');
}
if (typeof(Module) === "undefined") Module = { preRun: [] };
Module.preRun.push(gnunet_prerun);
-var init_continuation;
-
-// Called by GNUNET_SERVICE_run and GNUNET_PROGRAM_run to perform
-// asynchronous setup tasks. Calls continuation when finished.
-worker_setup = function(continuation) {
- if (init_continuation === 'now')
- continuation();
- else
- init_continuation = continuation;
-};
-
// a map of window index to port
var windows = {};
// next available index
@@ -116,10 +106,7 @@ function get_message(ev) {
ev.target.postMessage({type: 'stdout', port: channel.port2},
[channel.port2]);
FS.writeFile('/private_key', ev.data['private-key'], {encoding: 'binary'});
- if (typeof (init_continuation) === 'undefined')
- init_continuation = 'now';
- else
- init_continuation();
+ removeRunDependency('window-init');
} else if ('connect' == ev.data.type) {
SERVER.connect(ev.data.port);
}
diff --git a/src/js/program.js b/src/js/program.js
index de5aa50..776f513 100644
--- a/src/js/program.js
+++ b/src/js/program.js
@@ -23,9 +23,7 @@ mergeInto(LibraryManager.library, {
[binaryName, 'DEBUG', 0]);
var cfgfile = 0; // const char *
var cfg = 1; // opaque non-null pointer
- worker_setup(function() {
- Runtime.dynCall('viiii', task, [task_cls, argv, cfgfile, cfg]);
- });
+ Runtime.dynCall('viiii', task, [task_cls, argv, cfgfile, cfg]);
throw 'SimulateInfiniteLoop';
}
});
diff --git a/src/js/service.js b/src/js/service.js
index 1fc5f09..b1a92bf 100644
--- a/src/js/service.js
+++ b/src/js/service.js
@@ -23,9 +23,7 @@ mergeInto(LibraryManager.library, {
[service_name, 'DEBUG', 0]);
var server = 1; // opaque non-null pointer
var cfg = 2; // same
- worker_setup(function() {
- Runtime.dynCall('viii', task, [task_cls, server, cfg]);
- });
+ Runtime.dynCall('viii', task, [task_cls, server, cfg]);
throw 'SimulateInfiniteLoop';
}
});