summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library.js1
-rw-r--r--src/library_browser.js6
-rw-r--r--src/postamble.js4
-rw-r--r--src/preamble.js5
-rw-r--r--src/settings.js2
-rw-r--r--tests/test_browser.py4
-rw-r--r--tests/test_sockets.py1
7 files changed, 21 insertions, 2 deletions
diff --git a/src/library.js b/src/library.js
index d41498b1..f69b52e5 100644
--- a/src/library.js
+++ b/src/library.js
@@ -7517,6 +7517,7 @@ LibraryManager.library = {
} else {
{{{ makeSetValue('ai', C_STRUCTS.addrinfo.ai_addrlen, C_STRUCTS.sockaddr_in.__size__, 'i32') }}};
}
+ {{{ makeSetValue('ai', C_STRUCTS.addrinfo.ai_next, '0', 'i32') }}};
return ai;
}
diff --git a/src/library_browser.js b/src/library_browser.js
index 5d53b867..d6526d9c 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -675,6 +675,8 @@ mergeInto(LibraryManager.library, {
},
emscripten_async_prepare: function(file, onload, onerror) {
+ Module['noExitRuntime'] = true;
+
var _file = Pointer_stringify(file);
var data = FS.analyzePath(_file);
if (!data.exists) return -1;
@@ -694,6 +696,8 @@ mergeInto(LibraryManager.library, {
},
emscripten_async_prepare_data: function(data, size, suffix, arg, onload, onerror) {
+ Module['noExitRuntime'] = true;
+
var _suffix = Pointer_stringify(suffix);
if (!Browser.asyncPrepareDataCounter) Browser.asyncPrepareDataCounter = 0;
var name = 'prepare_data_' + (Browser.asyncPrepareDataCounter++) + '.' + _suffix;
@@ -954,6 +958,8 @@ mergeInto(LibraryManager.library, {
},
emscripten_call_worker: function(id, funcName, data, size, callback, arg) {
+ Module['noExitRuntime'] = true; // should we only do this if there is a callback?
+
funcName = Pointer_stringify(funcName);
var info = Browser.workers[id];
var callbackId = -1;
diff --git a/src/postamble.js b/src/postamble.js
index 90a86474..382d3117 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -202,6 +202,10 @@ if (Module['noInitialRun']) {
shouldRunNow = false;
}
+#if NO_EXIT_RUNTIME
+Module["noExitRuntime"] = true;
+#endif
+
run();
// {{POST_RUN_ADDITIONS}}
diff --git a/src/preamble.js b/src/preamble.js
index 25ef1fb3..5038e9c4 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -1027,6 +1027,11 @@ function preMain() {
}
function exitRuntime() {
+#if ASSERTIONS
+ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
+ Module.printErr('Exiting runtime. Any attempt to access the compiled C code may fail from now. If you want to keep the runtime alive, set Module["noExitRuntime"] = true or build with -s NO_EXIT_RUNTIME=1');
+ }
+#endif
callRuntimeCallbacks(__ATEXIT__);
}
diff --git a/src/settings.js b/src/settings.js
index 79e949fa..1db91dca 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -48,6 +48,8 @@ var VERBOSE = 0; // When set to 1, will generate more verbose output during comp
var INVOKE_RUN = 1; // Whether we will run the main() function. Disable if you embed the generated
// code in your own, and will call main() yourself at the right time (which you
// can do with Module.callMain(), with an optional parameter of commandline args).
+var NO_EXIT_RUNTIME = 0; // If set, the runtime is not quit when main() completes (allowing code to
+ // run afterwards, for example from the browser main event loop).
var INIT_HEAP = 0; // Whether to initialize memory anywhere other than the stack to 0.
var TOTAL_STACK = 5*1024*1024; // The total stack size. There is no way to enlarge the stack, so this
// value must be large enough for the program's requirements. If
diff --git a/tests/test_browser.py b/tests/test_browser.py
index 54d42397..8bcd708e 100644
--- a/tests/test_browser.py
+++ b/tests/test_browser.py
@@ -783,7 +783,7 @@ window.close = function() {
''')
open(os.path.join(self.get_dir(), 'sdl_key.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_key.c')).read()))
- Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'sdl_key.c'), '-o', 'page.html', '--pre-js', 'pre.js', '-s', '''EXPORTED_FUNCTIONS=['_main', '_one']''']).communicate()
+ Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'sdl_key.c'), '-o', 'page.html', '--pre-js', 'pre.js', '-s', '''EXPORTED_FUNCTIONS=['_main', '_one']''', '-s', 'NO_EXIT_RUNTIME=1']).communicate()
self.run_browser('page.html', '', '/report_result?223092870')
def test_sdl_key_proxy(self):
@@ -830,7 +830,7 @@ keydown(100);keyup(100); // trigger the end
</body>''')
open('test.html', 'w').write(html)
- self.btest('sdl_key_proxy.c', '223092870', args=['--proxy-to-worker', '--pre-js', 'pre.js', '-s', '''EXPORTED_FUNCTIONS=['_main', '_one']'''], manual_reference=True, post_build=post)
+ self.btest('sdl_key_proxy.c', '223092870', args=['--proxy-to-worker', '--pre-js', 'pre.js', '-s', '''EXPORTED_FUNCTIONS=['_main', '_one']''', '-s', 'NO_EXIT_RUNTIME=1'], manual_reference=True, post_build=post)
def test_sdl_text(self):
open(os.path.join(self.get_dir(), 'pre.js'), 'w').write('''
diff --git a/tests/test_sockets.py b/tests/test_sockets.py
index f9dcbc68..3a5555ed 100644
--- a/tests/test_sockets.py
+++ b/tests/test_sockets.py
@@ -220,6 +220,7 @@ class sockets(BrowserCore):
)
def test_getaddrinfo(self):
+ self.emcc_args=[]
self.do_run(open(path_from_root('tests', 'sockets', 'test_getaddrinfo.c')).read(), 'success')
def test_getnameinfo(self):