Fix thread safety issue 18/209618/2
authorJunghoon Park <jh9216.park@samsung.com>
Tue, 9 Jul 2019 09:31:04 +0000 (18:31 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Thu, 11 Jul 2019 04:26:10 +0000 (13:26 +0900)
- Free cb_info at main thread to fix thread safety issue

Change-Id: If11ba25c5760a7401f9f3ccf7e8f6bb6a32997e2
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
client/src/pkgmgr.c

index 6273ebb..3fba80c 100644 (file)
@@ -151,10 +151,19 @@ static struct cb_info *__create_size_info_cb_info(
        return cb_info;
 }
 
-static void __free_cb_info(struct cb_info *cb_info)
+static gboolean __free_cb_info_at_main_thread(gpointer user_data)
 {
+       struct cb_info *cb_info = (struct cb_info *)user_data;
+
        free(cb_info->req_key);
        free(cb_info);
+
+       return G_SOURCE_REMOVE;
+}
+
+static void __free_cb_info(struct cb_info *cb_info)
+{
+       g_idle_add(__free_cb_info_at_main_thread, cb_info);
 }
 
 static int __get_size_process(pkgmgr_client *pc, const char *pkgid, uid_t uid,