diff options
author | Hyunho Kang <hhstark.kang@samsung.com> | 2016-10-10 14:22:23 +0900 |
---|---|---|
committer | Hyunho Kang <hhstark.kang@samsung.com> | 2016-10-10 14:52:49 +0900 |
commit | 7d79c58489ed4590885eb9de957d5c8ad98669fc (patch) | |
tree | 8722e7b825713ddf9bcc0e4a354f977679c269d8 | |
parent | 88711b815d2bbaf125ca6119eae7ab876772b962 (diff) | |
download | message-port-7d79c58489ed4590885eb9de957d5c8ad98669fc.tar.gz message-port-7d79c58489ed4590885eb9de957d5c8ad98669fc.tar.bz2 message-port-7d79c58489ed4590885eb9de957d5c8ad98669fc.zip |
Add EAGAIN/EWOULDBLOCK error handlingsubmit/tizen_3.0_common/20161104.104000submit/tizen_3.0/20161028.082323submit/tizen_3.0/20161028.062323submit/tizen/20161010.043049accepted/tizen/wearable/20161010.083222accepted/tizen/tv/20161010.083208accepted/tizen/mobile/20161010.083148accepted/tizen/ivi/20161010.083240accepted/tizen/common/20161010.145842accepted/tizen/3.0/wearable/20161028.122736accepted/tizen/3.0/tv/20161028.122521accepted/tizen/3.0/mobile/20161028.122222accepted/tizen/3.0/ivi/20161028.122947
- wrt(nodejs) can change blocking socket to none blocking socket
Change-Id: I1846a58aaf14f391558bbe404542990d373d072a
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
-rwxr-xr-x | src/message-port.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/message-port.c b/src/message-port.c index eb86b2f..995df34 100755 --- a/src/message-port.c +++ b/src/message-port.c @@ -50,7 +50,7 @@ #define DBUS_RELEASE_NAME_REPLY_NON_EXISTENT 2 /* *< The given name does not exist on the bus */ #define DBUS_RELEASE_NAME_REPLY_NOT_OWNER 3 /* *< Service is not an owner of the given name */ #define HEADER_LEN 8 -#define MAX_RETRY_CNT 2 +#define MAX_RETRY_CNT 10 #define SOCK_PAIR_SENDER 0 #define SOCK_PAIR_RECEIVER 1 @@ -593,6 +593,7 @@ static int __read_socket(int fd, unsigned int left = nbytes; ssize_t nb; int retry_cnt = 0; + const struct timespec TRY_SLEEP_TIME = { 0, 500 * 1000 * 1000 }; *bytes_read = 0; while (left && (retry_cnt < MAX_RETRY_CNT)) { @@ -601,9 +602,11 @@ static int __read_socket(int fd, LOGE("__read_socket: ...read EOF, socket closed %d: nb %d\n", fd, nb); return MESSAGEPORT_ERROR_IO_ERROR; } else if (nb == -1) { - if (errno == EINTR) { - LOGE("__read_socket: EINTR error continue ..."); + /* wrt(nodejs) could change socket to none-blocking socket :-( */ + if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) { + 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); |