common: Modify glib threads to be unreferenced 70/314670/1 accepted/tizen/unified/20240718.143632 accepted/tizen/unified/dev/20240722.073434 accepted/tizen/unified/x/20240719.012648
authorSangYoun Kwak <sy.kwak@samsung.com>
Wed, 17 Jul 2024 06:20:04 +0000 (15:20 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Wed, 17 Jul 2024 06:27:59 +0000 (15:27 +0900)
To trigger update, GThread is used and it is created by g_thread_try_new
function. This function returns GThread object(pointer), which is a
newly allocated resource. Since update-manager does not manage these
threads with join, this resource should be unreferenced.

To unreference GThread, g_thread_unref is called. Since the thread holds
its GThread reference, it is safe to unreference the GThread.

Change-Id: Id656b9404b21ce5d859356beea0717c2481bc724
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
update-manager/common/common-dbus-manager.c

index a422c05bdade8aa36345a952e1ec8b886d4d59b8..ebaec6920af766d020c38be0a758ccbe1f6caba4 100644 (file)
@@ -97,12 +97,14 @@ gboolean dbus_manager_ro_update(OrgTizenUpdateManager *skeleton, GDBusMethodInvo
        arg->invocation = invocation;
 
        GError *error = NULL;
-       g_thread_try_new(NULL, (GThreadFunc)dbus_call_handler, (void *)arg, &error);
+       GThread *thread = g_thread_try_new(NULL, (GThreadFunc)dbus_call_handler, (void *)arg, &error);
        if (error != NULL) {
                _FLOGE("Failed to create thread: %s", error->message);
                goto fail;
        }
 
+       g_thread_unref(thread);
+
        return TRUE;
 
 fail:
@@ -127,12 +129,14 @@ gboolean dbus_manager_finish_update(OrgTizenUpdateManager *skeleton, GDBusMethod
        arg->invocation = invocation;
 
        GError *error = NULL;
-       g_thread_try_new(NULL, (GThreadFunc)dbus_call_handler, (void *)arg, &error);
+       GThread *thread = g_thread_try_new(NULL, (GThreadFunc)dbus_call_handler, (void *)arg, &error);
        if (error != NULL) {
                _FLOGE("Failed to create thread: %s", error->message);
                goto fail;
        }
 
+       g_thread_unref(thread);
+
        return TRUE;
 
 fail:
@@ -161,12 +165,14 @@ gboolean dbus_manager_ro_update_and_finish_update(OrgTizenUpdateManager *skeleto
        arg->invocation = invocation;
 
        GError *error = NULL;
-       g_thread_try_new(NULL, (GThreadFunc)dbus_call_handler, (void *)arg, &error);
+       GThread *thread = g_thread_try_new(NULL, (GThreadFunc)dbus_call_handler, (void *)arg, &error);
        if (error != NULL) {
                _FLOGE("Failed to create thread: %s", error->message);
                goto fail;
        }
 
+       g_thread_unref(thread);
+
        return TRUE;
 
 fail: