Increased wait time and error handling
[platform/core/pim/pims-ipc.git] / src / pims-ipc.c
index 3de9e26..a936105 100644 (file)
@@ -400,16 +400,20 @@ static int __pims_ipc_receive(pims_ipc_s *handle, pims_ipc_data_h *data_out)
 
        while (1) {
                while (1) {
-                       ret = poll(pollfds, 1, 1000);
+                       ret = poll(pollfds, 1, 4500);
                        if (ret == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
                                continue;
 
                        break;
                }
 
+               if (ret == 0){
+                       ERR("timedout errno[%d], revents[%d]", errno, pollfds[0].revents);
+                       return -1;
+               }
                if (ret > 0) {
                        if (pollfds[0].revents & (POLLERR|POLLHUP)) {
-                               ERR("Server disconnected");
+                               ERR("Server disconnected ret[%d]", ret);
                                ret = -1;
                                break;
                        }
@@ -720,6 +724,7 @@ static pims_ipc_h __pims_ipc_create(char *service, pims_ipc_mode_e mode)
                        break;
                }
                VERBOSE("connect to server : socket:%s, client_sock:%d, %d\n", handle->service, handle->fd, ret);
+               DBG("connect to server : socket:%s, client_sock:%d, %d\n", handle->service, handle->fd, ret);
 
                if (mode == PIMS_IPC_MODE_REQ) {
                        GIOChannel *ch = g_io_channel_unix_new(handle->fd);
@@ -733,7 +738,11 @@ static pims_ipc_h __pims_ipc_create(char *service, pims_ipc_mode_e mode)
                                ERR("__pims_ipc_send_identify error");
                                break;
                        }
-                       __pims_ipc_receive(handle, NULL);
+                       ret = __pims_ipc_receive(handle, NULL);
+                       if (ret < 0) {
+                               ERR("__pims_ipc_receive error");
+                               break;
+                       }
 
                        if (pims_ipc_call(handle, PIMS_IPC_MODULE_INTERNAL, PIMS_IPC_FUNCTION_CREATE, NULL, NULL) != 0)
                                WARN("pims_ipc_call(PIMS_IPC_FUNCTION_CREATE) failed");