Refactor dbus_handle_init into two parts 65/174865/4 accepted/tizen/unified/20180406.061936 submit/tizen/20180405.024125 submit/tizen/20180405.044417 submit/tizen/20180405.051333 submit/tizen/20180405.111955
authorlokilee73 <changjoo.lee@samsung.com>
Wed, 4 Apr 2018 12:39:46 +0000 (21:39 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Thu, 5 Apr 2018 02:23:49 +0000 (11:23 +0900)
It's to solve timing issue caused by telephony.
When it requests AddPoweroffWait, it fails because dbus in deviced is not ready.

Change-Id: I03f64928e361301ba87330298a19bd7482317081
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
src/core/main.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 2c06b1b..8d4768c
@@ -87,6 +87,7 @@ static gboolean watchdog_cb(void *data)
 static int deviced_main(int argc, char **argv)
 {
        int ret;
+       dbus_handle_h handle = NULL;
 
        mainloop = g_main_loop_new(NULL, FALSE);
 
@@ -94,11 +95,18 @@ static int deviced_main(int argc, char **argv)
        if (ret)
                return 0;
 
-       if (!dbus_handle_init(G_BUS_TYPE_SYSTEM, DEVICED_BUS_NAME, deviced_dbus_name_acquired, NULL)) {
-               _E("failed to init dbus connection");
-       }
+       handle = dbus_handle_get_connection(G_BUS_TYPE_SYSTEM, FALSE);
+       if (!handle)
+               _E("Fail to get dbus connection");
+
        devices_init(NULL);
 
+       ret = dbus_handle_request_bus_name(handle, DEVICED_BUS_NAME, deviced_dbus_name_acquired, NULL);
+       if (ret <= 0) {
+               _E("Fail to request bus name");
+               dbus_handle_check_owner_name(NULL, DEVICED_BUS_NAME);
+       }
+
        signal(SIGTERM, sig_quit);
        signal(SIGUSR1, sig_usr1);