thermal: Change order of initialization 08/210608/2
authorDongwoo Lee <dwoo08.lee@samsung.com>
Fri, 19 Jul 2019 03:33:55 +0000 (12:33 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Tue, 23 Jul 2019 06:40:18 +0000 (15:40 +0900)
To prevent race condition, dbus object should be registered before
well-known name is acquired. This patch changes order of initilizing
to fit this precondition.

Change-Id: I9fe60af8ed542155d26cc9c8a5f88eade3b38bb5
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
src/thermal/thermal.c

index 0baecd3a20689e16daa8ccddadb9e7664860667e..2858248c4c3fd964318316423410973f9cce1cc6 100644 (file)
@@ -319,14 +319,6 @@ static int thermal_probe(void *data)
                return -ENOENT;
        }
 
-       ret = pass_gdbus_get_name(PASS_DBUS_THERMAL,
-                               DBUS_THERMAL_BUS_NAME, NULL);
-       if (ret < 0) {
-               _E("Failed to own dbus name '%s'\n", DBUS_THERMAL_BUS_NAME);
-               ret = -EINVAL;
-               goto out;
-       }
-
        /* Initialize the d-bus interface for Thermal Monitor */
        g_gdbus_instance = pass_gdbus_get_instance_thermal();
        if (!g_gdbus_instance) {
@@ -336,6 +328,14 @@ static int thermal_probe(void *data)
                goto out;
        }
 
+       ret = pass_gdbus_get_name(PASS_DBUS_THERMAL,
+                               DBUS_THERMAL_BUS_NAME, NULL);
+       if (ret < 0) {
+               _E("Failed to own dbus name '%s'\n", DBUS_THERMAL_BUS_NAME);
+               ret = -EINVAL;
+               goto out;
+       }
+
        ret = pass_gdbus_connect_signal(g_gdbus_instance,
                        ARRAY_SIZE(g_gdbus_signal_infos), g_gdbus_signal_infos);
        if (ret < 0) {