From f5b88f70979048877da0ebfca69eb80f8cd3e3cc Mon Sep 17 00:00:00 2001 From: Dongwoo Lee Date: Fri, 19 Jul 2019 12:33:55 +0900 Subject: [PATCH] thermal: Change order of initialization 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 --- src/thermal/thermal.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/thermal/thermal.c b/src/thermal/thermal.c index 0baecd3..2858248 100644 --- a/src/thermal/thermal.c +++ b/src/thermal/thermal.c @@ -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) { -- 2.34.1