[FIX] exit of "already running" processes 63/52663/4 tizen_2.4_uihv
authorAnatolii Nikulin <nikulin.a@samsung.com>
Wed, 25 Nov 2015 11:22:46 +0000 (14:22 +0300)
committerDmitry Kovalenko <d.kovalenko@samsung.com>
Fri, 27 Nov 2015 05:29:34 +0000 (21:29 -0800)
Send message APP_MSG_STOP_WITHOUT_KILL
for stopping instrumentation of already running applications
without exit

Change-Id: Idb74c8b9d232fd8bde84e97e3d91a7fcd419916d
Signed-off-by: Anatolii Nikulin <nikulin.a@samsung.com>
daemon/daemon.c
daemon/target.c
daemon/target.h

index 959d63b..a54b155 100644 (file)
@@ -300,21 +300,10 @@ static int exec_app(const struct app_info_t *app_info)
        return res;
 }
 
-// just send stop message to all target process
-static void terminate_all_target()
-{
-       struct msg_target_t msg = {
-               .type = APP_MSG_STOP,
-               .length = 0
-       };
-
-       target_send_msg_to_all(&msg);
-}
-
 // terminate all target and wait for threads
 void terminate_all()
 {
-       terminate_all_target();
+       target_send_terminate_to_all();
 
        // wait for all other thread exit
        target_wait_all();
@@ -621,7 +610,7 @@ static pid_t get_current_pid(void)
        return pid;
 }
 
-static void target_set_type(struct target *t)
+static void target_set_type(struct target *t, struct app_info_t *info)
 {
        pid_t ppid = target_get_ppid(t);
        enum app_type_t app_type = APP_TYPE_UNKNOWN;
@@ -630,6 +619,8 @@ static void target_set_type(struct target *t)
                app_type = APP_TYPE_COMMON;
        } else if (get_lpad_pid(ppid) == ppid) {
                app_type = APP_TYPE_TIZEN;
+       } else if (info && info->app_type == APP_TYPE_RUNNING) {
+               app_type = APP_TYPE_RUNNING;
        }
 
        t->app_type = app_type;
@@ -640,23 +631,19 @@ static int target_event_pid_handler(struct target *target)
 {
        struct app_list_t *app = NULL;
        struct app_info_t *app_info = NULL;
-
-       target_set_type(target);
+       pid_t pid = target_get_pid(target);
 
        /* posible need some process check right there before start_replay >> */
-       app_info = app_info_get_first(&app);
-       if (app_info == NULL) {
-               LOGE("No app info found\n");
-               return -1;
-       }
-
-       while (app_info != NULL) {
-               if (is_same_app_process(app_info->exe_path,
-                                       target_get_pid(target)))
+       for (app_info = app_info_get_first(&app);
+            app_info != NULL;
+            app_info = app_info_get_next(&app))
+       {
+               if (is_same_app_process(app_info->exe_path, pid))
                        break;
-               app_info = app_info_get_next(&app);
        }
 
+       target_set_type(target, app_info);
+
        if (app_info == NULL) {
                LOGE("pid %d not found in app list\n",
                     target_get_pid(target));
index f70200e..c16ebdc 100644 (file)
@@ -254,6 +254,34 @@ int target_send_msg_to_all(struct msg_target_t *msg)
        return ret;
 }
 
+int target_send_terminate_to_all(void)
+{
+       int i, ret = 0;
+
+       target_array_lock();
+       for (i = 0; i < MAX_TARGET_COUNT; i++) {
+               struct target *t;
+               struct msg_target_t msg;
+
+               if (target_use[i] == 0)
+                       continue;
+
+               t = target_get(i);
+               if (t->app_type == APP_TYPE_RUNNING) {
+                       msg.type = APP_MSG_STOP_WITHOUT_KILL;
+                       msg.length = 0;
+               } else {
+                       msg.type = APP_MSG_STOP;
+                       msg.length = 0;
+               }
+               if (target_send_msg(t, &msg))
+                               ret = 1;
+       }
+       target_array_unlock();
+
+       return ret;
+}
+
 void target_wait_all(void)
 {
        int i;
index 2abba94..ac09db9 100644 (file)
@@ -89,6 +89,7 @@ struct target *target_get(int i);
 
 /* for all targets */
 int target_send_msg_to_all(struct msg_target_t *msg);
+int target_send_terminate_to_all(void);
 void target_wait_all(void);
 uint64_t target_get_total_alloc(pid_t pid);