Add EAGAIN error handling 75/64875/4 accepted/tizen/common/20160413.130956 accepted/tizen/ivi/20160413.123449 accepted/tizen/mobile/20160413.123217 accepted/tizen/tv/20160413.123400 accepted/tizen/wearable/20160413.123422 submit/tizen/20160412.075243
authorHyunho Kang <hhstark.kang@samsung.com>
Mon, 11 Apr 2016 04:28:56 +0000 (13:28 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Tue, 12 Apr 2016 03:06:08 +0000 (12:06 +0900)
- nodejs can change blocking socket to none blocking socket

Change-Id: I03b917fcdad0f11b080505d2b097774277799cde
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
src/data-control-internal.c

index 6caba2f6014c213b224e7cf789459b8c22715293..b9f6a9e0bd6182c20b6bffb7d88de3395d65196d 100755 (executable)
@@ -42,7 +42,7 @@
 #define RESULT_VALUE_COUNT                     "RESULT_VALUE_COUNT"
 #define MAX_COUNT_PER_PAGE             "MAX_COUNT_PER_PAGE"
 #define RESULT_PAGE_NUMBER             "RESULT_PAGE_NUMBER"
-#define MAX_RETRY                      5
+#define MAX_RETRY                      10
 
 #define ERR_BUFFER_SIZE         1024
 #define BUFSIZE 512
@@ -94,6 +94,7 @@ int _read_socket(int fd, char *buffer, unsigned int nbytes,
        unsigned int left = nbytes;
        gsize nb;
        int retry_cnt = 0;
+       const struct timespec TRY_SLEEP_TIME = { 0, 500 * 1000 * 1000 };
 
        *bytes_read = 0;
        while (left && (retry_cnt < MAX_RETRY)) {
@@ -103,9 +104,10 @@ int _read_socket(int fd, char *buffer, unsigned int nbytes,
                        LOGE("_read_socket: ...read EOF, socket closed %d: nb %d\n", fd, nb);
                        return DATACONTROL_ERROR_IO_ERROR;
                } else if (nb == -1) {
-                       if (errno == EINTR) {
-                               LOGE("_read_socket: EINTR error continue ...");
+                       if (errno == EINTR || errno == EAGAIN) {
+                               LOGE("_read_socket: %d errno, sleep and retry ...", errno);
                                retry_cnt++;
+                               nanosleep(&TRY_SLEEP_TIME, 0);
                                continue;
                        }
                        LOGE("_read_socket: ...error fd %d: errno %d\n", fd, errno);