added TEMP_FAILURE_RETRY for read 56/39956/3
authorJeesun Kim <iamjs.kim@samsung.com>
Wed, 27 May 2015 02:09:25 +0000 (11:09 +0900)
committerJeesun Kim <iamjs.kim@samsung.com>
Thu, 4 Jun 2015 01:38:10 +0000 (10:38 +0900)
Change-Id: I9bd70d352110ce3698111dcf4725ecb709327ef9

CMakeLists.txt
src/pims-ipc-svc.c
src/pims-ipc.c
src/pims-socket.c

index 55de936..38985c5 100755 (executable)
@@ -33,6 +33,7 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC")
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -Wall -g -fPIC -std=c++0x")
 
 ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-D_GNU_SOURCE")
 
 ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
 SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${MAJORVER})
index 925335d..ceb24e1 100644 (file)
@@ -16,7 +16,6 @@
  * limitations under the License.
  */
 
-
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -1209,12 +1208,12 @@ static int __recv_raw_data(int fd, pims_ipc_raw_data_s **data, bool *identity)
 
        do {
                // total length
-               ret = read(fd, (void *)&total_len, sizeof(unsigned int));
+               ret = TEMP_FAILURE_RETRY(read(fd, (void *)&total_len, sizeof(unsigned int)));
                if (ret < 0) {   ERROR("read error"); break;            }
                read_len += ret;
 
                // client_id
-               ret  = read(fd, (void *)&(temp->client_id_len), sizeof(unsigned int));
+               ret  = TEMP_FAILURE_RETRY(read(fd, (void *)&(temp->client_id_len), sizeof(unsigned int)));
                if (ret < 0) {   ERROR("read error"); break;            }
                read_len += ret;
 
@@ -1224,7 +1223,7 @@ static int __recv_raw_data(int fd, pims_ipc_raw_data_s **data, bool *identity)
                read_len += ret;
 
                // sequnce no
-               ret = read(fd, (void *)&(temp->seq_no), sizeof(unsigned int));
+               ret = TEMP_FAILURE_RETRY(read(fd, (void *)&(temp->seq_no), sizeof(unsigned int)));
                if (ret < 0) {   ERROR("read error"); break;            }
                read_len += ret;
 
@@ -1235,7 +1234,7 @@ static int __recv_raw_data(int fd, pims_ipc_raw_data_s **data, bool *identity)
                }
 
                // call_id
-               ret  = read(fd, (void *)&(temp->call_id_len), sizeof(unsigned int));
+               ret  = TEMP_FAILURE_RETRY(read(fd, (void *)&(temp->call_id_len), sizeof(unsigned int)));
                if (ret < 0)    { ERROR("read error"); break;           }
                read_len += ret;
 
@@ -1245,14 +1244,14 @@ static int __recv_raw_data(int fd, pims_ipc_raw_data_s **data, bool *identity)
                read_len += ret;
 
                // is_data
-               ret = read(fd, (void *)&(is_data), sizeof(unsigned int));
+               ret = TEMP_FAILURE_RETRY(read(fd, (void *)&(is_data), sizeof(unsigned int)));
                if (ret < 0) {   ERROR("read error"); break;            }
                read_len += ret;
 
                // data
                if (is_data) {
                        temp->is_data = TRUE;
-                       ret = read(fd, (void *)&(temp->data_len), sizeof(unsigned int));
+                       ret = TEMP_FAILURE_RETRY(read(fd, (void *)&(temp->data_len), sizeof(unsigned int)));
                        if (ret < 0) {  ERROR("read error"); break;             }
                        read_len += ret;
 
index 3529476..816681b 100644 (file)
@@ -16,7 +16,6 @@
  * limitations under the License.
  */
 
-
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -289,10 +288,10 @@ static int __pims_ipc_read_data(pims_ipc_s *handle, pims_ipc_data_h *data_out)
                unsigned int is_data = FALSE;
 
                // get total_len
-               read_len = read(handle->fd, (void *)&total_len, sizeof(unsigned int));
+               read_len = TEMP_FAILURE_RETRY(read(handle->fd, (void *)&total_len, sizeof(unsigned int)));
 
                // client_id
-               read_len += read(handle->fd, (void *)&(client_id_len), sizeof(unsigned int));
+               read_len += TEMP_FAILURE_RETRY(read(handle->fd, (void *)&(client_id_len), sizeof(unsigned int)));
                if (client_id_len > 0 && client_id_len < UINT_MAX-1) {
                        client_id = calloc(1, client_id_len+1);
                        if (client_id == NULL) {
@@ -307,7 +306,7 @@ static int __pims_ipc_read_data(pims_ipc_s *handle, pims_ipc_data_h *data_out)
                read_len += ret;
 
                // sequence no
-               read_len += read(handle->fd, (void *)&(sequence_no), sizeof(unsigned int));
+               read_len += TEMP_FAILURE_RETRY(read(handle->fd, (void *)&(sequence_no), sizeof(unsigned int)));
                if (total_len == read_len) {
                        // send identity
                        data = pims_ipc_data_create(0);
@@ -317,7 +316,7 @@ static int __pims_ipc_read_data(pims_ipc_s *handle, pims_ipc_data_h *data_out)
                        break;
                }
 
-               read_len += read(handle->fd, (void *)&(call_id_len), sizeof(unsigned int));
+               read_len += TEMP_FAILURE_RETRY(read(handle->fd, (void *)&(call_id_len), sizeof(unsigned int)));
                if (call_id_len > 0 && call_id_len < UINT_MAX-1) {
                        call_id = calloc(1, call_id_len+1);
                        if (call_id == NULL) {
@@ -332,10 +331,10 @@ static int __pims_ipc_read_data(pims_ipc_s *handle, pims_ipc_data_h *data_out)
                if (ret < 0) {  ERROR("socket_recv error"); break;      }
                read_len += ret;
 
-               read_len += read(handle->fd, (void *)&(is_data), sizeof(unsigned int));
+               read_len += TEMP_FAILURE_RETRY(read(handle->fd, (void *)&(is_data), sizeof(unsigned int)));
                if (is_data) {
                        unsigned int data_len;
-                       read_len += read(handle->fd, (void *)&(data_len), sizeof(unsigned int));
+                       read_len += TEMP_FAILURE_RETRY(read(handle->fd, (void *)&(data_len), sizeof(unsigned int)));
                        if (data_len > 0 && data_len < UINT_MAX-1) {
                                buf = calloc(1, data_len+1);
                                if (buf == NULL) {
@@ -462,10 +461,10 @@ static int __subscribe_data(pims_ipc_s * handle)
                unsigned int is_data = FALSE;
 
                // get total_len
-               read_len = read(handle->fd, (void *)&total_len, sizeof(unsigned int));
+               read_len = TEMP_FAILURE_RETRY(read(handle->fd, (void *)&total_len, sizeof(unsigned int)));
 
                // call_id
-               read_len += read(handle->fd, (void *)&(call_id_len), sizeof(unsigned int));
+               read_len += TEMP_FAILURE_RETRY(read(handle->fd, (void *)&(call_id_len), sizeof(unsigned int)));
                if (call_id_len > 0 && call_id_len < UINT_MAX-1) {
                        call_id = calloc(1, call_id_len+1);
                        if (call_id == NULL) {
@@ -481,11 +480,11 @@ static int __subscribe_data(pims_ipc_s * handle)
                read_len += ret;
 
                // is_data
-               read_len += read(handle->fd, (void *)&(is_data), sizeof(unsigned int));
+               read_len += TEMP_FAILURE_RETRY(read(handle->fd, (void *)&(is_data), sizeof(unsigned int)));
 
                if (is_data) {
                        unsigned int data_len;
-                       read_len += read(handle->fd, (void *)&(data_len), sizeof(unsigned int));
+                       read_len += TEMP_FAILURE_RETRY(read(handle->fd, (void *)&(data_len), sizeof(unsigned int)));
                        if (data_len > 0 && data_len < UINT_MAX-1) {
                                buf = calloc(1, data_len+1);
                                if (buf == NULL) {
index eff803d..5cc146d 100644 (file)
@@ -163,7 +163,7 @@ int write_command(int fd, const uint64_t cmd)
 int read_command(int fd, uint64_t *cmd)
 {
        uint64_t dummy;
-       int len = read(fd, &dummy, sizeof(dummy));
+       int len = TEMP_FAILURE_RETRY(read(fd, &dummy, sizeof(dummy)));
        if (len == sizeof(dummy)) {
                *cmd = dummy;
        }