Fix bugs about sending dbus signal 10/236610/3
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 18 Jun 2020 22:07:43 +0000 (07:07 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Thu, 18 Jun 2020 23:19:32 +0000 (23:19 +0000)
If flushing a pending signal is failed, launchpad should not create and
store a new pending item from it.

Change-Id: Ieb72efd4c16d92610f1aa7a20dc741cd16e0998b
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/launchpad/src/launchpad_dbus.c

index 171612b..e408b3c 100644 (file)
@@ -146,48 +146,32 @@ static int __emit_signal(const char *path,
 
 static int __emit_app_launch_signal(int pid, const char *app_id)
 {
-       pending_item_t *item;
        int ret;
 
        ret = __emit_signal(AUL_DBUS_PATH,
                        AUL_DBUS_SIGNAL_INTERFACE,
                        AUL_DBUS_APPLAUNCH_SIGNAL,
                        g_variant_new("(us)", pid, app_id));
-       if (ret < 0) {
-               item = __create_pending_item(app_id, pid, APP_SIGNAL_LAUNCH);
-               if (!item)
-                       return -ENOMEM;
+       if (ret < 0)
+               return ret;
 
-               _W("Pend app launch signal. pid(%d), app_id(%s)", pid, app_id);
-               __pending_items = g_list_append(__pending_items, item);
-               __set_pending_item_timer();
-       } else {
-               _D("App launch. pid(%d), app_id(%s)", pid, app_id);
-       }
+       _D("App launch. pid(%d), app_id(%s)", pid, app_id);
 
        return 0;
 }
 
 static int __emit_app_dead_signal(int pid)
 {
-       pending_item_t *item;
        int ret;
 
        ret = __emit_signal(AUL_DBUS_PATH,
                        AUL_DBUS_SIGNAL_INTERFACE,
                        AUL_DBUS_APPDEAD_SIGNAL,
                        g_variant_new("(u)", pid));
-       if (ret < 0) {
-               item = __create_pending_item(NULL, pid, APP_SIGNAL_DEAD);
-               if (!item)
-                       return -ENOMEM;
+       if (ret < 0)
+               return ret;
 
-               _W("Pend app dead signal. pid(%d)", pid);
-               __pending_items = g_list_append(__pending_items, item);
-               __set_pending_item_timer();
-       } else {
-               _D("App dead. pid(%d)", pid);
-       }
+       _D("App dead. pid(%d)", pid);
 
        return 0;
 }
@@ -243,22 +227,50 @@ static void __unset_pending_item_timer(void)
 
 int _dbus_send_app_launch_signal(int pid, const char *app_id)
 {
+       pending_item_t *item;
+       int ret;
+
        if (pid <= 1 || !app_id) {
                _E("Invalid parameter");
                return -EINVAL;
        }
 
-       return __emit_app_launch_signal(pid, app_id);
+       ret = __emit_app_launch_signal(pid, app_id);
+       if (ret < 0) {
+               item = __create_pending_item(app_id, pid, APP_SIGNAL_LAUNCH);
+               if (!item)
+                       return -ENOMEM;
+
+               _W("Pend app launch signal. pid(%d), app_id(%s)", pid, app_id);
+               __pending_items = g_list_append(__pending_items, item);
+               __set_pending_item_timer();
+       }
+
+       return 0;
 }
 
 int _dbus_send_app_dead_signal(int pid)
 {
+       pending_item_t *item;
+       int ret;
+
        if (pid <= 1) {
                _E("Invalid parameter");
                return -EINVAL;
        }
 
-       return __emit_app_dead_signal(pid);
+       ret = __emit_app_dead_signal(pid);
+       if (ret < 0) {
+               item = __create_pending_item(NULL, pid, APP_SIGNAL_DEAD);
+               if (!item)
+                       return -ENOMEM;
+
+               _W("Pend app dead signal. pid(%d)", pid);
+               __pending_items = g_list_append(__pending_items, item);
+               __set_pending_item_timer();
+       }
+
+       return 0;
 }
 
 int _dbus_init(void)