From afdc4f81832dbbda2bbaa6807da5d5a9725f9a5f Mon Sep 17 00:00:00 2001 From: Youngjae Shin Date: Tue, 16 Jul 2013 13:18:33 +0900 Subject: [PATCH] Revert "fix socket i/o bug" This reverts commit e6c5edfa4ae34728c8d5e00655c42f651126e2d8. --- src/clientlib/net_nfc_client_ipc.c | 44 +++++--------------------------------- src/manager/net_nfc_server_ipc.c | 42 +++--------------------------------- 2 files changed, 8 insertions(+), 78 deletions(-) diff --git a/src/clientlib/net_nfc_client_ipc.c b/src/clientlib/net_nfc_client_ipc.c index abb6eec..dffeaea 100755 --- a/src/clientlib/net_nfc_client_ipc.c +++ b/src/clientlib/net_nfc_client_ipc.c @@ -82,40 +82,6 @@ inline void net_nfc_client_ipc_unlock() pthread_mutex_unlock(&g_client_ipc_mutex); } -static inline int _client_safe_send(int fd, void *message, int length, int flag) -{ - int ret, sended=0; - while (length) { - ret = send(fd, message+sended, length, flag); - if (-1 == ret) { - if (EINTR == errno) - continue; - else - return ret; - } - sended += ret; - length -= ret; - } - return sended; -} - -static inline int _client_safe_recv(int fd, void *message, int length) -{ - int ret, received=0; - while (length) { - ret = recv(fd, message+received, length, 0); - if (-1 == ret) { - if (EINTR == errno) - continue; - else - return ret; - } - received += ret; - length -= ret; - } - return received; -} - static void net_nfc_client_prepare_sync_call(net_nfc_request_msg_t *msg) { net_nfc_client_ipc_lock(); @@ -706,7 +672,7 @@ int __net_nfc_client_read_util(void **detail, size_t size) int length; static uint8_t flushing[128]; - if (_client_safe_recv(g_client_sock_fd, &length, sizeof(length)) != sizeof(length)) + if (recv(g_client_sock_fd, &length, sizeof(length), 0) != sizeof(length)) { return 0; } @@ -722,7 +688,7 @@ int __net_nfc_client_read_util(void **detail, size_t size) while (readbytes > 0) { read_size = readbytes > 128 ? 128 : readbytes; - if (_client_safe_recv(g_client_sock_fd, flushing, read_size) <= 0) + if (recv(g_client_sock_fd, flushing, read_size, 0) <= 0) { return 0; } @@ -731,7 +697,7 @@ int __net_nfc_client_read_util(void **detail, size_t size) return 0; } /* read */ - if (_client_safe_recv(g_client_sock_fd, *detail, size) <= 0) + if (recv(g_client_sock_fd, *detail, size, 0) <= 0) { _net_nfc_util_free_mem(*detail); return 0; @@ -751,7 +717,7 @@ net_nfc_response_msg_t *net_nfc_client_read_response_msg(net_nfc_error_e *result return NULL; } - if (_client_safe_recv(g_client_sock_fd, (void *)&(resp_msg->response_type), sizeof(int)) != sizeof(int)) + if (recv(g_client_sock_fd, (void *)&(resp_msg->response_type), sizeof(int), 0) != sizeof(int)) { DEBUG_ERR_MSG("reading message is failed"); _net_nfc_util_free_mem(resp_msg); @@ -1607,7 +1573,7 @@ net_nfc_response_msg_t *net_nfc_client_read_response_msg(net_nfc_error_e *result bool __net_nfc_client_send_msg(void *message, int length) { - bool result = (_client_safe_send(g_client_sock_fd, (void *)message, length, MSG_NOSIGNAL) > 0); + bool result = (send(g_client_sock_fd, (void *)message, length, MSG_NOSIGNAL) > 0); if (result == false) { diff --git a/src/manager/net_nfc_server_ipc.c b/src/manager/net_nfc_server_ipc.c index a4b818d..5832598 100755 --- a/src/manager/net_nfc_server_ipc.c +++ b/src/manager/net_nfc_server_ipc.c @@ -66,42 +66,6 @@ static bool net_nfc_server_process_client_connect_request(); ///////////////////////// -static inline int _server_safe_send(int fd, void *message, int length, int flag) -{ - int ret, sended=0; - while (length) { - ret = send(fd, message+sended, length, flag); - if (-1 == ret) { - if (EINTR == errno) - continue; - else - return ret; - } - sended += ret; - length -= ret; - } - return sended; -} - - -static inline int _server_safe_recv(int fd, void *message, int length) -{ - int ret, received=0; - while (length) { - ret = recv(fd, message+received, length, 0); - if (-1 == ret) { - if (EINTR == errno) - continue; - else - return ret; - } - received += ret; - length -= ret; - } - return received; -} - - bool net_nfc_server_set_server_state(uint32_t state) { pthread_mutex_lock(&g_server_socket_lock); @@ -682,7 +646,7 @@ bool net_nfc_server_send_message_to_client(int socket, void *message, int length bool result = true; pthread_mutex_lock(&g_server_socket_lock); - len = _server_safe_send(socket, (void *)message, length, MSG_NOSIGNAL); + len = send(socket, (void *)message, length, MSG_NOSIGNAL); pthread_mutex_unlock(&g_server_socket_lock); if (len <= 0) @@ -703,7 +667,7 @@ bool net_nfc_server_send_message_to_client(int socket, void *message, int length bool net_nfc_server_send_message_to_client(void* message, int length) { pthread_mutex_lock(&g_server_socket_lock); - int leng = _server_safe_send(g_server_info.client_sock_fd, (void *)message, length, 0); + int leng = send(g_server_info.client_sock_fd, (void *)message, length, 0); pthread_mutex_unlock(&g_server_socket_lock); if(leng > 0) @@ -720,7 +684,7 @@ bool net_nfc_server_send_message_to_client(void* message, int length) int net_nfc_server_recv_message_from_client(int client_sock_fd, void* message, int length) { - int leng = _server_safe_recv(client_sock_fd, message, length); + int leng = recv(client_sock_fd, message, length, 0); return leng; } -- 2.7.4