Call "Add_Poweroff_Wait" dbus method asynchronously. 82/245982/3 submit/tizen/20201104.070405
authorYunmi Ha <yunmi.ha@samsung.com>
Wed, 21 Oct 2020 06:07:47 +0000 (15:07 +0900)
committerYunmi Ha <yunmi.ha@samsung.com>
Wed, 21 Oct 2020 10:01:19 +0000 (19:01 +0900)
Change-Id: I8b0b9a152971aa8cf196897606a4f2ba4878e460
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
src/block/block.c

index 3ce6739..357a64f 100644 (file)
@@ -2678,6 +2678,22 @@ static void remove_whole_block_device(void)
        }
 }
 
+static void add_poweroff_wait_cb(GVariant *var, void *user_data, GError *err)
+{
+       int ret_val = -ENOMSG;
+
+       if (!var)
+               return ;
+
+       if (!g_variant_get_safe(var, "(i)", &ret_val))
+               _E("Failed to get(%s): no message", g_variant_get_type_string(var));
+
+       if (ret_val >= 0)
+               add_poweroff_wait = true;
+
+       g_variant_unref(var);
+}
+
 static void booting_done(void)
 {
        static int done = 0;
@@ -2697,15 +2713,15 @@ static void booting_done(void)
        /* if there is the attached device, try to mount */
        block_init_from_udev_enumerate();
 
-       ret = dbus_handle_method_sync(DEVICED_BUS_NAME,
+       ret = dbus_handle_method_async_with_reply(DEVICED_BUS_NAME,
                DEVICED_PATH_POWEROFF,
                DEVICED_INTERFACE_POWEROFF,
                METHOD_ADD_POWEROFF_WAIT,
-               NULL, NULL);
+               NULL, NULL,
+               add_poweroff_wait_cb,
+               -1, NULL);
        if (ret < 0)
                _E("Failed to call "METHOD_ADD_POWEROFF_WAIT" method.");
-       else
-               add_poweroff_wait = true;
 
        block_boot = true;
 }