You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Don't call `exitRuntime()` when `ENVIRONMENT_IS_PTHREAD` is true.
- Only obtain `runtimeKeepaliveCounter` when `EXIT_RUNTIME` is true.
- Remove the early return from `exitRuntime()`.
- Collapse if/else statements in `exit()`.
Copy file name to clipboardExpand all lines: src/postamble.js
+20-18Lines changed: 20 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -411,24 +411,25 @@ function exit(status, implicit) {
411
411
#endif // ASSERTIONS && !EXIT_RUNTIME
412
412
413
413
#if USE_PTHREADS
414
-
if(!implicit){
415
-
if(ENVIRONMENT_IS_PTHREAD){
416
-
#if PTHREADS_DEBUG
417
-
err('Pthread 0x'+_pthread_self().toString(16)+' called exit(), posting exitOnMainThread.');
418
-
#endif
419
-
// When running in a pthread we propagate the exit back to the main thread
420
-
// where it can decide if the whole process should be shut down or not.
421
-
// The pthread may have decided not to exit its own runtime, for example
422
-
// because it runs a main loop, but that doesn't affect the main thread.
423
-
exitOnMainThread(status);
424
-
throw'unwind';
425
-
}else{
414
+
if(ENVIRONMENT_IS_PTHREAD){
415
+
#if ASSERTIONS
416
+
assert(!implicit,"exit should never be called implicitly in a pthread");
417
+
#endif
426
418
#if PTHREADS_DEBUG
427
-
err('main thread called exit: keepRuntimeAlive='+keepRuntimeAlive()+' (counter='+runtimeKeepaliveCounter+')');
419
+
err('Pthread 0x'+_pthread_self().toString(16)+' called exit(), posting exitOnMainThread.');
420
+
#endif
421
+
// When running in a pthread we propagate the exit back to the main thread
422
+
// where it can decide if the whole process should be shut down or not.
423
+
// The pthread may have decided not to exit its own runtime, for example
424
+
// because it runs a main loop, but that doesn't affect the main thread.
425
+
exitOnMainThread(status);
426
+
throw'unwind';
427
+
#if EXIT_RUNTIME&&PTHREADS_DEBUG
428
+
}elseif(!implicit){
429
+
err('main thread called exit: keepRuntimeAlive='+keepRuntimeAlive()+' (counter='+runtimeKeepaliveCounter+')');
428
430
#endif
429
-
}
430
431
}
431
-
#endif
432
+
#endif// USE_PTHREADS
432
433
433
434
#if EXIT_RUNTIME
434
435
if(!keepRuntimeAlive()){
@@ -437,12 +438,13 @@ function exit(status, implicit) {
437
438
#endif
438
439
439
440
#if ASSERTIONS
441
+
#if EXIT_RUNTIME
440
442
// if exit() was called explicitly, warn the user if the runtime isn't actually being shut down
443
+
elseif(!implicit){
444
+
varmsg='program exited (with status: '+status+'), but keepRuntimeAlive() is set (counter='+runtimeKeepaliveCounter+') due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)';
445
+
#else // !EXIT_RUNTIME
441
446
if(keepRuntimeAlive()&&!implicit){
442
-
#if !EXIT_RUNTIME
443
447
varmsg='program exited (with status: '+status+'), but EXIT_RUNTIME is not set, so halting execution but not exiting the runtime or preventing further async execution (build with EXIT_RUNTIME=1, if you want a true shutdown)';
444
-
#else
445
-
varmsg='program exited (with status: '+status+'), but keepRuntimeAlive() is set (counter='+runtimeKeepaliveCounter+') due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)';
Copy file name to clipboardExpand all lines: src/worker.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -274,7 +274,7 @@ self.onmessage = (e) => {
274
274
}
275
275
#if ASSERTIONS
276
276
}else{
277
-
// else e == 'unwind', and we should fall through here and keep the pthread alive for asynchronous events.
277
+
// else ex == 'unwind', and we should fall through here and keep the pthread alive for asynchronous events.
278
278
err('Pthread 0x'+Module['_pthread_self']().toString(16)+' completed its main entry point with an `unwind`, keeping the worker alive for asynchronous operation.');
0 commit comments