Tizen 2.4 SDK Rev6 Release accepted/tizen_2.3.1_mobile accepted/tizen_2.3.1_wearable tizen_2.3.1 accepted/tizen/2.3.1/mobile/20160530.053451 accepted/tizen/2.3.1/wearable/20160530.053444 submit/tizen_2.3.1/20160530.021337
authorJaekyu Park <jk7744.park@samsung.com>
Fri, 27 May 2016 08:13:27 +0000 (17:13 +0900)
committerJaekyu Park <jk7744.park@samsung.com>
Fri, 27 May 2016 08:13:27 +0000 (17:13 +0900)
am_daemon/amd_launch.c
am_daemon/amd_request.c
am_daemon/amd_status.c
src/app_sock.c

index cae9032..34196a8 100755 (executable)
@@ -796,6 +796,7 @@ static gboolean __recv_timeout_handler(gpointer data)
 {
        struct reply_info *r_info = (struct reply_info *) data;
        int fd = r_info->gpollfd->fd;
+       int ret = -EAGAIN;
 
        _E("application is not responding : pid(%d) cmd(%d)", r_info->pid, r_info->cmd);
 
@@ -817,11 +818,13 @@ static gboolean __recv_timeout_handler(gpointer data)
                        _E("fail to killing - %d\n", r_info->pid);
                        __real_send(r_info->clifd, -1);
                        return -1;
+               } else {
+                       ret = 0;
                }
-               __real_send(r_info->clifd, 0);
                break;
        }
 
+       __real_send(r_info->clifd, ret);
        g_source_remove_poll(r_info->src, r_info->gpollfd);
        g_source_destroy(r_info->src);
        g_free(r_info->gpollfd);
@@ -842,6 +845,8 @@ static void __set_reply_handler(int fd, int pid, int clifd, int cmd)
        if (gpollfd == NULL) {
                _E("out of memory");
                g_source_unref(src);
+               close(fd);
+               close(clifd);
                return;
        }
 
@@ -853,6 +858,8 @@ static void __set_reply_handler(int fd, int pid, int clifd, int cmd)
                _E("out of memory");
                g_free(gpollfd);
                g_source_unref(src);
+               close(fd);
+               close(clifd);
                return;
        }
 
@@ -1848,6 +1855,8 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
                if (pid > 0) {
                        if ((ret = __nofork_processing(cmd, pid, kb, fd)) < 0) {
                                pid = ret;
+                       } else {
+                               delay_reply = 1;
                        }
                } else if (cmd != APP_RESUME) {
 #ifdef _APPFW_FEATURE_DEBUG_LAUNCHPAD
index 3f75b6e..b080c66 100755 (executable)
@@ -66,6 +66,9 @@ static gboolean __request_handler(gpointer data);
 
 static int __send_result_to_client(int fd, int res)
 {
+       if (fd < 0)
+               return -1;
+
        _D("__send_result_to_client, res: %d", fd, res);
 
        if (send(fd, &res, sizeof(int), MSG_NOSIGNAL) < 0) {
@@ -81,9 +84,9 @@ static int __send_result_to_client(int fd, int res)
 
 static void __real_send(int clifd, int ret)
 {
-       if(clifd <= 0) {
+       if (clifd < 0)
                return;
-       }
+
        if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) {
                if (errno == EPIPE) {
                        _E("send failed due to EPIPE.\n");
@@ -154,12 +157,15 @@ static int __app_process_by_pid(int cmd,
        int ret = -1;
        int dummy;
 
-       if (pkg_name == NULL)
+       if (pkg_name == NULL) {
+               close(clifd);
                return -1;
+       }
 
        pid = atoi(pkg_name);
        if (pid <= 1) {
                _E("invalid pid");
+               close(clifd);
                return -1;
        }
 
@@ -167,6 +173,7 @@ static int __app_process_by_pid(int cmd,
                char buf[512];
                if (_status_get_pkgname_bypid(pid, buf, 512) == -1) {
                        _E("request for unknown pid. It might not be a pid of app: %d", pid);
+                       __real_send(clifd, -1);
                        return -1;
                }
        }
index b74bec5..3a3a1c7 100755 (executable)
@@ -246,6 +246,7 @@ int _status_send_running_appinfo(int fd)
        pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
        if(!pkt) {
                _E("malloc fail");
+               close(fd);
                return 0;
        }
 
index 29d95c2..d776e2f 100755 (executable)
@@ -40,13 +40,18 @@ static int __connect_client_sock(int sockfd, const struct sockaddr *saptr, sockl
 static inline void __set_sock_option(int fd, int cli)
 {
        int size;
+       int flag;
        struct timeval tv = { 5, 200 * 1000 };  /*  5.2 sec */
 
        size = AUL_SOCK_MAXBUFF;
        setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
        setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
-       if (cli)
+       if (cli) {
                setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+               flag = fcntl(fd, F_GETFD);
+               flag |= FD_CLOEXEC;
+               fcntl(fd, F_SETFD, flag);
+       }
 }
 
 int __create_server_sock(int pid)
@@ -282,6 +287,7 @@ int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
        pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
        if (NULL == pkt) {
                _E("Malloc Failed!");
+               close(fd);
                return -ENOMEM;
        }
        memset(pkt, 0, AUL_SOCK_MAXBUFF);
@@ -370,6 +376,7 @@ int __app_send_raw_with_noreply(int pid, int cmd, unsigned char *kb_data, int da
        pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
        if (NULL == pkt) {
                _E("Malloc Failed!");
+               close(fd);
                return -ENOMEM;
        }
        memset(pkt, 0, AUL_SOCK_MAXBUFF);
@@ -441,6 +448,7 @@ int __app_send_raw_with_delay_reply(int pid, int cmd, unsigned char *kb_data, in
        pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
        if (NULL == pkt) {
                _E("Malloc Failed!");
+               close(fd);
                return -ENOMEM;
        }
        memset(pkt, 0, AUL_SOCK_MAXBUFF);
@@ -576,6 +584,7 @@ app_pkt_t *__app_send_cmd_with_result(int pid, int cmd, unsigned char *kb_data,
        pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
        if (NULL == pkt) {
                _E("Malloc Failed!");
+               close(fd);
                return NULL;
        }
        memset(pkt, 0, AUL_SOCK_MAXBUFF);