stop control thread during shutdown to prevent crashes 1.2.0_rc3
authorTimo Lotterbach <timo.lotterbach@bmw-carit.de>
Mon, 7 Apr 2014 08:59:45 +0000 (10:59 +0200)
committerTimo Lotterbach <timo.lotterbach@bmw-carit.de>
Mon, 7 Apr 2014 08:59:45 +0000 (10:59 +0200)
unit tests do fast init/destroy cycles, which resulted in control
thread still using resources (e.g. display) that were already destroyed.

Signed-off-by: Timo Lotterbach <timo.lotterbach@bmw-carit.de>
ivi-layermanagement-api/ilmCommon/src/ilm_common.c
ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c

index f487f79..540ebf5 100644 (file)
@@ -86,5 +86,8 @@ ilm_isInitialized()
 ILM_EXPORT ilmErrorTypes
 ilm_destroy()
 {
-    return gIlmCommonPlatformFunc.destroy();
+    ilmErrorTypes retVal = gIlmCommonPlatformFunc.destroy();
+    ilmClient_destroy();
+    ilmControl_destroy(); // block until control thread is stopped
+    return retVal;
 }
index dceb0e8..4f63c39 100644 (file)
@@ -1429,6 +1429,11 @@ wayland_destroy()
 {
     struct ilm_control_context *ctx = &ilm_context;
     ctx->valid = 0;
+    void* threadRetVal = NULL;
+    pthread_cancel(ctx->thread);
+    if (0 != pthread_join(ctx->thread, &threadRetVal)) {
+        fprintf(stderr, "failed to join control thread\n");
+    }
 }
 
 static void