--- old/src/java.base/solaris/native/libnet/solaris_close.c 2016-09-07 18:50:56.517239468 +0530 +++ new/src/java.base/solaris/native/libnet/solaris_close.c 2016-09-07 18:50:56.081238732 +0530 @@ -35,7 +35,7 @@ if (1) { \ do { \ _result = _cmd; \ - } while((_result == -1) && (errno == EINTR)); \ + } while((_result == -1) && (errno == EINTR)); \ return _result; \ } \ } while(0) @@ -44,6 +44,10 @@ RESTARTABLE_RETURN_INT(recv(s, buf, len, 0)); } +int NET_NonBlockingRead(int s, void* buf, size_t len) { + RESTARTABLE_RETURN_INT(recv(s, buf, len, MSG_DONTWAIT)); +} + int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen) { RESTARTABLE_RETURN_INT(recvfrom(s, buf, len, flags, from, fromlen)); @@ -86,19 +90,14 @@ RESTARTABLE_RETURN_INT(poll(ufds, nfds, timeout)); } -int NET_Timeout(int s, long timeout) { +int NET_Timeout0(int s, long timeout,long currentTime) { int result; struct timeval t; - long prevtime, newtime; + long prevtime = currentTime, newtime; struct pollfd pfd; pfd.fd = s; pfd.events = POLLIN; - - if (timeout > 0) { - gettimeofday(&t, NULL); - prevtime = (t.tv_sec * 1000) + t.tv_usec / 1000; - } - + for(;;) { result = poll(&pfd, 1, timeout); if (result < 0 && errno == EINTR) { @@ -115,3 +114,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); +}