summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunho Kang <hhstark.kang@samsung.com>2016-10-10 14:22:23 +0900
committerHyunho Kang <hhstark.kang@samsung.com>2016-10-10 14:52:49 +0900
commit7d79c58489ed4590885eb9de957d5c8ad98669fc (patch)
tree8722e7b825713ddf9bcc0e4a354f977679c269d8
parent88711b815d2bbaf125ca6119eae7ab876772b962 (diff)
downloadmessage-port-7d79c58489ed4590885eb9de957d5c8ad98669fc.tar.gz
message-port-7d79c58489ed4590885eb9de957d5c8ad98669fc.tar.bz2
message-port-7d79c58489ed4590885eb9de957d5c8ad98669fc.zip
- wrt(nodejs) can change blocking socket to none blocking socket Change-Id: I1846a58aaf14f391558bbe404542990d373d072a Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
-rwxr-xr-xsrc/message-port.c9
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);