SUGGESTED FIX
src/solaris/native/java/net/net_util_md.c
@@ -1318,11 +1318,11 @@
* NET_WAIT_READ, NET_WAIT_WRITE & NET_WAIT_CONNECT.
*
* The function will return when either the socket is ready for one
* of the specified operation or the timeout expired.
*
- * It returns the time left from the timeout, or -1 if it expired.
+ * It returns the time left from the timeout (possibly 0), or -1 if it expired.
*/
jint
NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
{
@@ -1371,14 +1371,10 @@
errno = 0;
read_rv = NET_Select(fd+1, &rd, &wr, &ex, &t);
}
#endif
- if (read_rv > 0) {
- break;
- }
-
newTime = JVM_CurrentTimeMillis(env, 0);
timeout -= (newTime - prevTime);
if (timeout <= 0) {
return read_rv > 0 ? 0 : -1;
}
|
EVALUATION
Both the ping4 and ping6 implementations use the private native function, NET_Wait, to poll for incoming events on the socket. The Net_Wait function will return when either the socket is ready for one of the specified events or the timeout has expired. It is specified to return the time left from the timeout (possibly 0) or -1 if it has expired, but currently if an event has been received it returns the timeout as passed into the function. This leads to the timeout in both the IPv4 and IPv6 ping implementations to never be decremented if there are any incoming ICMP packets. This is as a consequence of the raw socket seeing all ICMP packets received by the interface.
|