tpl: Fixed an issue runtime_fini was not thread safe. 43/170743/1 sandbox/lsj119/devel
authorjoonbum.ko <joonbum.ko@samsung.com>
Thu, 22 Feb 2018 02:05:31 +0000 (11:05 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Thu, 22 Feb 2018 02:05:31 +0000 (11:05 +0900)
Change-Id: Iea2ae18e9b2dd6042fa1e86eda54fa8ef7b5fdb6
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
src/tpl.c

index d29e9de..7c834ce 100644 (file)
--- a/src/tpl.c
+++ b/src/tpl.c
@@ -38,19 +38,21 @@ __tpl_init(void)
 static void __attribute__((destructor))
 __tpl_runtime_fini(void)
 {
-       if (runtime != NULL) {
-               int i;
-
-               if (!pthread_mutex_lock(&runtime_mutex)) {
+       if (!pthread_mutex_lock(&runtime_mutex)) {
+               if (runtime != NULL) {
+                       int i;
                        for (i = 0; i < TPL_BACKEND_COUNT; i++) {
                                if (runtime->displays[i] != NULL)
                                        __tpl_hashlist_destroy(&(runtime->displays[i]));
+                               if (runtime->surfaces[i] != NULL)
+                                       __tpl_hashlist_destroy(&(runtime->surfaces[i]));
                        }
-                       pthread_mutex_unlock(&runtime_mutex);
+
+                       free(runtime);
+                       runtime = NULL;
                }
 
-               free(runtime);
-               runtime = NULL;
+               pthread_mutex_unlock(&runtime_mutex);
        }
 
 #ifdef OBJECT_HASH_CHECK