Rollback to socket as blocking mode 46/107746/4
authorYoungHun Kim <yh8004.kim@samsung.com>
Thu, 29 Dec 2016 12:48:29 +0000 (21:48 +0900)
committerYoungHun Kim <yh8004.kim@samsung.com>
Fri, 30 Dec 2016 05:31:53 +0000 (21:31 -0800)
Change-Id: I6847cd61a0e2ef953405d0e3cbfee1fd9eec6284

src/muse_core.c
src/muse_core_ipc.c

index 1ac134e..abda21f 100644 (file)
@@ -258,8 +258,8 @@ static int _muse_core_server_new(muse_core_channel_e channel)
                return SOCK_ERR;
        }
 
-       if (_muse_core_set_nonblocking(fd, true) < 0) /* non-blocking */
-               LOGE("failed to set server socket to non-blocking");
+       if (_muse_core_set_nonblocking(fd, false) < 0) /* blocking */
+               LOGE("failed to set server socket to blocking");
 
        return fd;
 }
@@ -355,13 +355,8 @@ static int _muse_core_client_new(muse_core_channel_e channel)
        strncpy(address.sun_path, UDS_files[channel], sizeof(address.sun_path));
        len = sizeof(address);
 
-       if (channel == MUSE_CHANNEL_MSG) {
-               if (_muse_core_set_nonblocking(sockfd, false) != MM_ERROR_NONE)
-                       LOGE("Error - fd (%d) set blocking", sockfd);
-       } else if (channel == MUSE_CHANNEL_DATA) {
-               if (_muse_core_set_nonblocking(sockfd, true) != MM_ERROR_NONE)
-                       LOGE("Error - fd (%d) set nonblocking", sockfd);
-       }
+       if (_muse_core_set_nonblocking(sockfd, false) != MM_ERROR_NONE)
+               LOGE("Error - fd (%d) set blocking", sockfd);
 
        if ((ret = connect(sockfd, (struct sockaddr *)&address, len)) < 0) {
                strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
index 78c3a24..41c61ea 100644 (file)
@@ -32,7 +32,6 @@
 #define MSG "msg"
 #define DATA "data"
 #define PID "pid"
-#define SEND_TRY 10
 
 typedef struct muse_recv_data_head {
        unsigned int marker;
@@ -689,8 +688,6 @@ int muse_core_ipc_push_data(int sock_fd, const char *data, int size, uint64_t da
        char err_msg[MUSE_MAX_ERROR_MSG_LEN] = {'\0',};
        muse_recv_data_head_t header;
        int sended_len = 0;
-       int head_size  = 0;
-       int send_try = 0;
 
        g_return_val_if_fail(data, MM_ERROR_INVALID_ARGUMENT);
 
@@ -701,30 +698,15 @@ int muse_core_ipc_push_data(int sock_fd, const char *data, int size, uint64_t da
        LOGI("[%d] header.marker : %x header.size : %d header.id : %"G_GUINT64_FORMAT"",
                                        sock_fd, header.marker, header.size, header.id);
 
-       head_size = sizeof(muse_recv_data_head_t);
-
-       do {
-               if ((sended_len = send(sock_fd, &header, head_size, 0)) < 0) {
-                       strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
-                       LOGE("fail to send msg (%s) %d", err_msg, errno);
-               } else {
-                       if (sended_len != head_size)
-                               LOGW("[SEND TRY : %d] %d /%d", send_try, sended_len, head_size);
-               }
-       } while ((sended_len != head_size) && (send_try++ < SEND_TRY));
-
-       send_try = 0;
-
-       do {
-               if ((sended_len += send(sock_fd, data, size, 0)) < 0) {
-                       strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
-                       LOGE("fail to send msg (%s) %d", err_msg, errno);
-               } else {
-                       if (sended_len != head_size + size)
-                               LOGW("[SEND TRY : %d] %d /%d", send_try, sended_len, head_size + size);
-               }
-       } while ((sended_len != head_size + size) && (send_try++ < SEND_TRY));
+       if ((sended_len = send(sock_fd, &header, sizeof(muse_recv_data_head_t), 0)) < 0) {
+               strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+               LOGE("[%d] fail to send msg (%s) %d", sock_fd, err_msg, errno);
+       }
 
+       if ((sended_len += send(sock_fd, data, size, 0)) < 0) {
+               strerror_r(errno, err_msg, MUSE_MAX_ERROR_MSG_LEN);
+               LOGE("[%d] fail to send msg (%s) %d", sock_fd, err_msg, errno);
+       }
 
        return sended_len;
 }