--- old/src/java.base/linux/native/libnet/linux_close.c 2016-09-07 11:27:02.068335481 +0530 +++ new/src/java.base/linux/native/libnet/linux_close.c 2016-09-07 11:27:01.632334745 +0530 @@ -367,6 +367,10 @@ BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) ); } +int NET_NonBlockingRead(int s, void* buf, size_t len) { + BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT) ); +} + int NET_ReadV(int s, const struct iovec * vector, int count) { BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) ); } @@ -406,8 +410,8 @@ * Auto restarts with adjusted timeout if interrupted by * signal other than our wakeup signal. */ -int NET_Timeout(int s, long timeout) { - long prevtime = 0, newtime; +int NET_Timeout0(int s, long timeout,long currentTime) { + long prevtime = currentTime, newtime; struct timeval t; fdEntry_t *fdEntry = getFdEntry(s); @@ -418,15 +422,7 @@ errno = EBADF; return -1; } - - /* - * Pick up current time as may need to adjust timeout - */ - if (timeout > 0) { - gettimeofday(&t, NULL); - prevtime = t.tv_sec * 1000 + t.tv_usec / 1000; - } - + for(;;) { struct pollfd pfd; int rv; @@ -463,3 +459,17 @@ } } + +int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime) { + return NET_Timeout0(s, timeout, currentTime); +} + +int NET_Timeout(int s, long timeout) { + long currentTime = 0; + struct timeval t; + if (timeout > 0) { + gettimeofday(&t, NULL); + currentTime = t.tv_sec * 1000 + t.tv_usec / 1000; + } + return NET_Timeout0(s, timeout, currentTime); +}