#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
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)) {
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);