summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2015-11-13 19:23:55 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2015-11-13 19:23:55 +0900
commit4a156e05bc6092396391633791c8361523f01642 (patch)
tree10639ba072cd6af7b064541e0c80fba142ef82f4
parentc68bd8e5a1f6fce682e6d957fac016914307aa1f (diff)
downloadaul-1-4a156e05bc6092396391633791c8361523f01642.tar.gz
aul-1-4a156e05bc6092396391633791c8361523f01642.tar.bz2
aul-1-4a156e05bc6092396391633791c8361523f01642.zip
- Add an exception when launching an app is STATUS_DYING - Fix operator precedence in _status_get_app_info_status() Change-Id: Ia5cf9cbda6a9f0f48eebf01c53a377827f0d1e99 Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--am_daemon/amd_launch.c36
-rw-r--r--am_daemon/amd_status.c43
2 files changed, 35 insertions, 44 deletions
diff --git a/am_daemon/amd_launch.c b/am_daemon/amd_launch.c
index 934639a9..adab09a3 100644
--- a/am_daemon/amd_launch.c
+++ b/am_daemon/amd_launch.c
@@ -616,6 +616,7 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
int delay_reply = 0;
int pad_pid = LAUNCHPAD_PID;
int lpid;
+ int callee_status = -1;
gboolean can_attach;
gboolean new_process;
app_group_launch_mode launch_mode;
@@ -636,9 +637,8 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
bundle_add(kb, AUL_K_CALLER_APPID, caller_appid);
} else {
caller_appid = _status_app_get_appid_bypid(getpgid(caller_pid));
- if (caller_appid != NULL) {
+ if (caller_appid != NULL)
bundle_add(kb, AUL_K_CALLER_APPID, caller_appid);
- }
}
ai = appinfo_find(caller_uid, appid);
@@ -666,9 +666,8 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
return ret;
multiple = appinfo_get_value(ai, AIT_MULTI);
- if (!multiple || strncmp(multiple, "false", 5) == 0) {
+ if (!multiple || strncmp(multiple, "false", 5) == 0)
pid = _status_app_is_running(appid, caller_uid);
- }
component_type = appinfo_get_value(ai, AIT_COMP);
if (strncmp(component_type, APP_TYPE_UI, strlen(APP_TYPE_UI)) == 0) {
@@ -680,22 +679,26 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
}
}
- if (pid > 0) {
- if (_status_get_app_info_status(pid, caller_uid) == STATUS_DYING) {
- pid = -ETERMINATING;
- } else if (caller_pid == pid) {
+ if (pid > 0)
+ callee_status = _status_get_app_info_status(pid, caller_uid);
+
+ if (pid > 0 && callee_status != STATUS_DYING) {
+ if (caller_pid == pid) {
SECURE_LOGD("caller process & callee process is same.[%s:%d]", appid, pid);
pid = -ELOCALLAUNCH_ID;
} else {
- if ((ret = __nofork_processing(cmd, pid, kb, fd)) < 0) {
+ if ((ret = __nofork_processing(cmd, pid, kb, fd)) < 0)
pid = ret;
- } else {
+ else
delay_reply = 1;
- }
}
- } else if (cmd == APP_RESUME) {
- _E("%s is not running", appid);
- } else {
+ } else if (cmd != APP_RESUME) {
+ if (callee_status == STATUS_DYING && pid > 0) {
+ ret = kill(pid, SIGKILL);
+ if (ret == -1)
+ _W("send SIGKILL: %s", strerror(errno));
+ }
+
hwacc = appinfo_get_value(ai, AIT_HWACC);
bundle_add(kb, AUL_K_HWACC, hwacc);
bundle_add(kb, AUL_K_EXEC, app_path);
@@ -711,11 +714,12 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
app_group_restart_app(pid, kb);
}
}
+ } else {
+ _E("Unknown application: %s", appid);
}
- if (pid > 0) {
+ if (pid > 0)
_status_add_app_info_list(appid, app_path, pid, pad_pid, caller_uid);
- }
if (!delay_reply)
__real_send(fd, pid);
diff --git a/am_daemon/amd_status.c b/am_daemon/amd_status.c
index ef2636bd..ddea373c 100644
--- a/am_daemon/amd_status.c
+++ b/am_daemon/amd_status.c
@@ -49,7 +49,7 @@ int _status_add_app_info_list(const char *appid, const char *app_path, int pid,
if(uid == info_t->uid)
return 0;
else {
- //PID is unique so if it is exist but user value is not correct remove it.
+ /* PID is unique so if it is exist but user value is not correct remove it. */
app_status_info_list = g_slist_remove(app_status_info_list, info_t);
free(info_t);
break;
@@ -70,8 +70,7 @@ int _status_add_app_info_list(const char *appid, const char *app_path, int pid,
info_t->uid = uid;
app_status_info_list = g_slist_append(app_status_info_list, info_t);
- for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
- {
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter)) {
info_t = (app_status_info_t *)iter->data;
SECURE_LOGD(" [%d] : %s, %d, %d", info_t->uid, info_t->appid, info_t->pid, info_t->status);
@@ -85,10 +84,9 @@ int _status_update_app_info_list(int pid, int status, uid_t uid)
GSList *iter = NULL;
app_status_info_t *info_t = NULL;
- for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
- {
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter)) {
info_t = (app_status_info_t *)iter->data;
- if((pid == info_t->pid) && ((info_t->uid == uid) || (info_t->uid == 0))) {
+ if ((pid == info_t->pid) && ((info_t->uid == uid) || (info_t->uid == 0))) {
info_t->status = status;
break;
}
@@ -113,6 +111,7 @@ int _status_remove_app_info_list_with_uid(uid_t uid)
free(info_t);
}
}
+
return 0;
}
@@ -131,13 +130,6 @@ int _status_remove_app_info_list(int pid, uid_t uid)
}
}
- for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
- {
- info_t = (app_status_info_t *)iter->data;
-
- //SECURE_LOGD("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
- }
-
return 0;
}
@@ -146,13 +138,11 @@ int _status_get_app_info_status(int pid, uid_t uid)
GSList *iter = NULL;
app_status_info_t *info_t = NULL;
- for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
- {
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter)) {
info_t = (app_status_info_t *)iter->data;
- if (pid == info_t->pid &&
- (uid == 0) ? true : (uid == info_t->uid)) {
+ if (pid == info_t->pid
+ && ((uid == 0) ? true : (uid == info_t->uid)))
return info_t->status;
- }
}
return app_group_get_status(pid);
@@ -163,13 +153,12 @@ int _status_app_is_running(const char *appid, uid_t uid)
GSList *iter = NULL;
app_status_info_t *info_t = NULL;
- for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
- {
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter)) {
info_t = (app_status_info_t *)iter->data;
- if(( strncmp(appid, info_t->appid, MAX_PACKAGE_STR_SIZE) == 0 ) && (info_t->uid == uid)) {
+ if ((strncmp(appid, info_t->appid, MAX_PACKAGE_STR_SIZE) == 0) && (info_t->uid == uid))
return info_t->pid;
- }
}
+
return -1;
}
@@ -178,13 +167,12 @@ char* _status_app_get_appid_bypid(int pid)
GSList *iter = NULL;
app_status_info_t *info_t = NULL;
- for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
- {
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter)) {
info_t = (app_status_info_t *)iter->data;
- if( pid == info_t->pid ) {
+ if (pid == info_t->pid)
return info_t->appid;
- }
}
+
return NULL;
}
@@ -197,8 +185,7 @@ int _status_send_running_appinfo(int fd, uid_t uid)
char tmp_pid[MAX_PID_STR_BUFSZ];
char buf[AUL_SOCK_MAXBUFF] = {0, };
- for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
- {
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter)) {
info_t = (app_status_info_t *)iter->data;
if (info_t->uid != uid || app_group_is_sub_app(info_t->pid))
continue;