--- a/jdk/src/java.base/solaris/native/libnet/solaris_close.c Mon May 01 11:18:07 2017 -0700
+++ b/jdk/src/java.base/solaris/native/libnet/solaris_close.c Tue May 02 16:39:29 2017 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
#include <sys/socket.h>
#include <stropts.h>
#include <unistd.h>
+#include "jvm.h"
+#include "net_util.h"
/* Support for restartable system calls on Solaris. */
@@ -90,25 +92,22 @@
RESTARTABLE_RETURN_INT(poll(ufds, nfds, timeout));
}
-int NET_Timeout0(int s, long timeout, long currentTime) {
+int NET_Timeout(JNIEnv *env, int s, long timeout, long nanoTimeStamp) {
int result;
- struct timeval t;
- long prevtime = currentTime, newtime;
+ long prevNanoTime = nanoTimeStamp;
+ long nanoTimeout = timeout * NET_NSEC_PER_MSEC;
struct pollfd pfd;
pfd.fd = s;
pfd.events = POLLIN;
for(;;) {
- result = poll(&pfd, 1, timeout);
+ result = poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
if (result < 0 && errno == EINTR) {
- if (timeout > 0) {
- gettimeofday(&t, NULL);
- newtime = (t.tv_sec * 1000) + t.tv_usec /1000;
- timeout -= newtime - prevtime;
- if (timeout <= 0)
- return 0;
- prevtime = newtime;
- }
+ long newNanoTime = JVM_NanoTime(env, 0);
+ nanoTimeout -= newNanoTime - prevNanoTime;
+ if (nanoTimeout < NET_NSEC_PER_MSEC)
+ return 0;
+ prevNanoTime = newNanoTime;
} else {
return result;
}