Rework deinit sequence to avoid bogus leak detector warnings.

This commit is contained in:
Nikolay Igotti
2017-12-12 12:53:52 +03:00
parent 899ad0740c
commit d0f1296c7e
2 changed files with 1 additions and 10 deletions
+1 -1
View File
@@ -127,7 +127,7 @@ void onThreadExit(void (*destructor)()) {
#ifdef KONAN_WASM
// No way to do that.
#else
::atexit(destructor);
#error "How to do onThreadExit()?"
#endif
#else // !KONAN_NO_THREADS
// We cannot use pthread_cleanup_push() as it is lexical scope bound.
-9
View File
@@ -82,15 +82,6 @@ void Kotlin_initRuntimeIfNeeded() {
runtimeState = initRuntime();
// Register runtime deinit function at thread cleanup.
konan::onThreadExit(Kotlin_deinitRuntimeIfNeeded);
#ifndef KONAN_WASM
// `onThreadExit` doesn't work on main thread, use `atexit`:
static bool deinitScheduledAtexit = false;
if (!deinitScheduledAtexit) {
deinitScheduledAtexit = true; // Having data race is OK here.
::atexit(Kotlin_deinitRuntimeIfNeeded);
}
#endif
}
}