[Title] fix prevent minor issues
authorgreatim <jaewon81.lim@samsung.com>
Tue, 30 Jul 2013 15:39:24 +0000 (00:39 +0900)
committergreatim <jaewon81.lim@samsung.com>
Tue, 30 Jul 2013 15:39:24 +0000 (00:39 +0900)
[Desc.]
[Issue]

Change-Id: I0ac502b3e76187cf16abcecc23afd57e10fa0ee5

daemon/daemon.c

index a393dd4..1884550 100644 (file)
@@ -270,7 +270,10 @@ int sendDataToHost(msg_t* log)
 //             loglen = sprintf(logstr, "%d|%s\n", log->type, log->data);
 
                pthread_mutex_lock(&(manager.host.data_socket_mutex));
-               send(manager.host.data_socket, logstr, loglen, MSG_NOSIGNAL);
+               if(0 > send(manager.host.data_socket, logstr, loglen, MSG_NOSIGNAL))
+               {
+                       LOGE("fail to send data to host(%d)\n", log->type);
+               }
                pthread_mutex_unlock(&(manager.host.data_socket_mutex));
                return 0;
        }
@@ -291,7 +294,10 @@ static int sendACKStrToHost(enum HostMessageType resp, char* msgstr)
                else
                        loglen = sprintf(logstr, "%d|0|", (int)resp);
 
-               send(manager.host.control_socket, logstr, loglen, MSG_NOSIGNAL);
+               if(0 > send(manager.host.control_socket, logstr, loglen, MSG_NOSIGNAL))
+               {
+                       LOGE("fail to send ACK string to host(%s)\n", logstr);
+               }
                return 0;
        }
        else
@@ -309,7 +315,10 @@ static int sendACKCodeToHost(enum HostMessageType resp, int msgcode)
                codelen = sprintf(codestr, "%d", msgcode);
                loglen = sprintf(logstr, "%d|%d|%s", (int)resp, codelen, codestr);
 
-               send(manager.host.control_socket, logstr, loglen, MSG_NOSIGNAL);
+               if(0 > send(manager.host.control_socket, logstr, loglen, MSG_NOSIGNAL))
+               {
+                       LOGE("fail to send ACK code to host(%s)\n", logstr);
+               }
                return 0;
        }
        else
@@ -724,7 +733,10 @@ static int hostMessageHandler(int efd, msg_t* log)
                        {
                                if(manager.target[i].socket != -1)
                                {
-                                       send(manager.target[i].socket, &sendlog, sizeof(sendlog.type) + sizeof(sendlog.length) + sendlog.length, MSG_NOSIGNAL);
+                                       if(0 > send(manager.target[i].socket, &sendlog, sizeof(sendlog.type) + sizeof(sendlog.length) + sendlog.length, MSG_NOSIGNAL))
+                                       {
+                                               LOGE("fail to send option to target(sock:%d)\n", manager.target[i].socket);
+                                       }
                                }
                        }
                }
@@ -867,7 +879,10 @@ static int targetEventHandler(int epollfd, int index, uint64_t msg)
                                manager.target[index].socket, manager.target[index].pid, manager.target_count - 1);
 
                terminate_target(index);
-               epoll_ctl(epollfd, EPOLL_CTL_DEL, manager.target[index].event_fd, NULL);
+               if(0 > epoll_ctl(epollfd, EPOLL_CTL_DEL, manager.target[index].event_fd, NULL))
+               {
+                       LOGW("fail to EPOLL DEL of event fd(%d)\n", index);
+               }
                setEmptyTargetSlot(index);
                if (0 == __sync_sub_and_fetch(&manager.target_count, 1))        // all target client are closed
                {
@@ -908,7 +923,10 @@ static int targetServerHandler(int efd)
                // send config message to target process
                log.type = MSG_OPTION;
                log.length = sprintf(log.data, "%u", manager.config_flag);
-               send(manager.target[index].socket, &log, sizeof(log.type) + sizeof(log.length) + log.length, MSG_NOSIGNAL);
+               if(0 > send(manager.target[index].socket, &log, sizeof(log.type) + sizeof(log.length) + log.length, MSG_NOSIGNAL))
+               {
+                       LOGE("fail to send initial option to target(sock:%d)\n", manager.target[index].socket); 
+               }
 
                // make event fd
                manager.target[index].event_fd = eventfd(0, EFD_NONBLOCK);
@@ -934,13 +952,19 @@ static int targetServerHandler(int efd)
                {
                        // fail to make recv thread
                        LOGE("fail to make recv thread for socket (%d)\n", manager.target[index].socket);
-                       epoll_ctl(efd, EPOLL_CTL_DEL, manager.target[index].event_fd, NULL);
+                       if(0 > epoll_ctl(efd, EPOLL_CTL_DEL, manager.target[index].event_fd, NULL))
+                       {
+                               LOGW("fail to EPOLL DEL of event fd(%d)\n", index);
+                       }
                        goto TARGET_CONNECT_FAIL;
                }
 
                if(manager.app_launch_timerfd >= 0)
                {
-                       epoll_ctl(efd, EPOLL_CTL_DEL, manager.app_launch_timerfd, NULL);
+                       if(0 > epoll_ctl(efd, EPOLL_CTL_DEL, manager.app_launch_timerfd, NULL))
+                       {
+                               LOGW("fail to EPOLL DEL of app launch timerfd\n");
+                       }
                        close(manager.app_launch_timerfd);
                        manager.app_launch_timerfd = -1;
                }
@@ -1248,7 +1272,10 @@ int daemonLoop()
                                recvLen = recv(manager.host.data_socket, recvBuf, 32, MSG_DONTWAIT);
                                if(recvLen == 0)
                                {       // close data socket
-                                       epoll_ctl(efd, EPOLL_CTL_DEL, manager.host.data_socket, NULL);
+                                       if(0 > epoll_ctl(efd, EPOLL_CTL_DEL, manager.host.data_socket, NULL))
+                                       {
+                                               LOGW("fail to EPOLL DEL of host data socket\n");
+                                       }
                                        close(manager.host.data_socket);
                                        manager.host.data_socket = -1;
                                }
@@ -1260,7 +1287,10 @@ int daemonLoop()
                        {
                                // send to host timeout error message for launching application
                                terminate_error("Failed to launch application", 1);
-                               epoll_ctl(efd, EPOLL_CTL_DEL, manager.app_launch_timerfd, NULL);
+                               if(0 > epoll_ctl(efd, EPOLL_CTL_DEL, manager.app_launch_timerfd, NULL))
+                               {
+                                       LOGW("fail to EPOLL DEL of app launch timerfd\n");
+                               }
                                close(manager.app_launch_timerfd);
                                manager.app_launch_timerfd = -1;
                                ret = -1;