Retry read() when getting EINTR 91/260891/1 accepted/tizen/unified/20210707.130433 submit/tizen/20210707.023406
authorSeonah Moon <seonah1.moon@samsung.com>
Tue, 6 Jul 2021 08:54:39 +0000 (17:54 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Tue, 6 Jul 2021 08:54:44 +0000 (17:54 +0900)
Change-Id: I476b3db2a3dfb6519d885c67c052914201eeca4c

packaging/download-provider.spec
provider/download-provider-ipc.c

index 282e703..4bdd3df 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       download-provider
 Summary:    Download the contents in background
-Version:    2.2.6
+Version:    2.2.7
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0
index d227179..dfe587e 100644 (file)
@@ -99,12 +99,26 @@ dp_ipc_fmt *dp_ipc_get_fmt(int sock)
                return NULL;
        }
        memset(ipc_info, 0x00, sizeof(dp_ipc_fmt));
-       ssize_t recv_size = read(sock, ipc_info, sizeof(dp_ipc_fmt));
-       if (recv_size <= 0 || recv_size != sizeof(dp_ipc_fmt)) {
-               TRACE_ERROR("socket read ipcinfo read size:%zd, errno:%d", recv_size, errno);
+
+       int errorcode = DP_ERROR_NONE;
+       int tryagain = 3;
+
+       do {
+               ssize_t recv_size = read(sock, ipc_info, sizeof(dp_ipc_fmt));
+               if (recv_size <= 0 || recv_size != sizeof(dp_ipc_fmt)) {
+                       TRACE_ERROR("socket read ipcinfo read size:%zd, errno:%d", recv_size, errno);
+                       errorcode = dp_ipc_check_stderr(errno);
+               } else {
+                       errorcode = DP_ERROR_NONE;
+               }
+       } while (sock >= 0 && (errorcode == DP_ERROR_IO_EINTR) && (--tryagain > 0));
+
+       if (errorcode != DP_ERROR_NONE) {
+               TRACE_ERROR("Failed to read sock[%d]", sock);
                free(ipc_info);
                return NULL;
        }
+
        return ipc_info;
 }