Refactor dbus_handle_init into two parts 66/174866/3 submit/tizen/20180405.024125
authorlokilee73 <changjoo.lee@samsung.com>
Wed, 4 Apr 2018 12:44:46 +0000 (21:44 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Thu, 5 Apr 2018 02:25:51 +0000 (11:25 +0900)
It's to apply a fix in deviced which timing issue happend by telephony.
When telephony requests AddPoweroffWait, it fails because dbus in deviced is not ready.

Change-Id: I7b333f0a43965ac75ccccf03262fae44dbea66ce
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 998dec2..53ca1c1
@@ -69,6 +69,7 @@ int main(int argc, char **argv)
 {
        int ret;
        guint timer;
+       dbus_handle_h handle = NULL;
 
        loop = g_main_loop_new(NULL, TRUE);
        if (!loop) {
@@ -76,12 +77,18 @@ int main(int argc, char **argv)
                return -ENOMEM;
        }
 
-       if (!dbus_handle_init(G_BUS_TYPE_SYSTEM, STORAGED_BUS_NAME, NULL, NULL)) {
-               _E("Failed to set dbus connection (%s)", STORAGED_BUS_NAME);
-               return 0;
-       }
+       handle = dbus_handle_get_connection(G_BUS_TYPE_SYSTEM, FALSE);
+       if (!handle)
+               _E("Fail to get dbus connection");;
 
        modules_init(NULL);
+
+       ret = dbus_handle_request_bus_name(handle, STORAGED_BUS_NAME, NULL, NULL);
+       if (ret <= 0) {
+               _E("Fail to request bus name");
+               dbush_handle_check_owner_name(NULL, STORAGED_BUS_NAME);
+       }
+
        signal(SIGTERM, sig_quit);
        signal(SIGUSR1, sig_usr1);