changeset 44921:0672237e13c0

8179602: Backout fix for JDK-8165437 due to breakage on 32-bit Linux Reviewed-by: chegar
author michaelm
date Thu, 04 May 2017 18:13:42 +0100
parents 5b66112437ba
children 9a62aeffc28c
files jdk/src/java.base/aix/native/libnet/aix_close.c jdk/src/java.base/linux/native/libnet/linux_close.c jdk/src/java.base/macosx/native/libnet/bsd_close.c jdk/src/java.base/solaris/native/libnet/solaris_close.c jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c jdk/src/java.base/unix/native/libnet/SocketInputStream.c jdk/src/java.base/unix/native/libnet/net_util_md.c jdk/src/java.base/unix/native/libnet/net_util_md.h
diffstat 9 files changed, 129 insertions(+), 107 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.base/aix/native/libnet/aix_close.c	Wed May 03 09:04:35 2017 -0700
+++ b/jdk/src/java.base/aix/native/libnet/aix_close.c	Thu May 04 18:13:42 2017 +0100
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2016, 2017, SAP SE and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, SAP SE 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
@@ -65,8 +65,6 @@
 #include <unistd.h>
 #include <errno.h>
 #include <sys/poll.h>
-#include "jvm.h"
-#include "net_util.h"
 
 /*
  * Stack allocated by thread when doing blocking operation
@@ -509,9 +507,9 @@
  * Auto restarts with adjusted timeout if interrupted by
  * signal other than our wakeup signal.
  */
-int NET_Timeout(JNIEnv *env, int s, long timeout, long nanoTimeStamp) {
-    long prevNanoTime = nanoTimeStamp;
-    long nanoTimeout = timeout * NET_NSEC_PER_MSEC;
+int NET_Timeout0(int s, long timeout, long currentTime) {
+    long prevtime = currentTime, newtime;
+    struct timeval t;
     fdEntry_t *fdEntry = getFdEntry(s);
 
     /*
@@ -535,7 +533,7 @@
         pfd.events = POLLIN | POLLERR;
 
         startOp(fdEntry, &self);
-        rv = poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
+        rv = poll(&pfd, 1, timeout);
         endOp(fdEntry, &self);
 
         /*
@@ -543,14 +541,18 @@
          * has expired return 0 (indicating timeout expired).
          */
         if (rv < 0 && errno == EINTR) {
-            long newNanoTime = JVM_NanoTime(env, 0);
-            nanoTimeout -= newNanoTime - prevNanoTime;
-            if (nanoTimeout < NET_NSEC_PER_MSEC) {
-                return 0;
+            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;
             }
-            prevNanoTime = newNanoTime;
         } else {
             return rv;
         }
+
     }
 }
--- a/jdk/src/java.base/linux/native/libnet/linux_close.c	Wed May 03 09:04:35 2017 -0700
+++ b/jdk/src/java.base/linux/native/libnet/linux_close.c	Thu May 04 18:13:42 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, 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
@@ -37,8 +37,6 @@
 #include <unistd.h>
 #include <errno.h>
 #include <sys/poll.h>
-#include "jvm.h"
-#include "net_util.h"
 
 /*
  * Stack allocated by thread when doing blocking operation
@@ -412,9 +410,9 @@
  * Auto restarts with adjusted timeout if interrupted by
  * signal other than our wakeup signal.
  */
-int NET_Timeout(JNIEnv *env, int s, long timeout, long nanoTimeStamp) {
-    long prevNanoTime = nanoTimeStamp;
-    long nanoTimeout = timeout * NET_NSEC_PER_MSEC;
+int NET_Timeout0(int s, long timeout, long currentTime) {
+    long prevtime = currentTime, newtime;
+    struct timeval t;
     fdEntry_t *fdEntry = getFdEntry(s);
 
     /*
@@ -438,7 +436,7 @@
         pfd.events = POLLIN | POLLERR;
 
         startOp(fdEntry, &self);
-        rv = poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
+        rv = poll(&pfd, 1, timeout);
         endOp(fdEntry, &self);
 
         /*
@@ -446,14 +444,18 @@
          * has expired return 0 (indicating timeout expired).
          */
         if (rv < 0 && errno == EINTR) {
-            long newNanoTime = JVM_NanoTime(env, 0);
-            nanoTimeout -= newNanoTime - prevNanoTime;
-            if (nanoTimeout < NET_NSEC_PER_MSEC) {
-                return 0;
+            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;
             }
-            prevNanoTime = newNanoTime;
         } else {
             return rv;
         }
+
     }
 }
--- a/jdk/src/java.base/macosx/native/libnet/bsd_close.c	Wed May 03 09:04:35 2017 -0700
+++ b/jdk/src/java.base/macosx/native/libnet/bsd_close.c	Thu May 04 18:13:42 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, 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
@@ -39,8 +39,6 @@
 #include <unistd.h>
 #include <errno.h>
 #include <sys/poll.h>
-#include "jvm.h"
-#include "net_util.h"
 
 /*
  * Stack allocated by thread when doing blocking operation
@@ -416,7 +414,8 @@
  * Auto restarts with adjusted timeout if interrupted by
  * signal other than our wakeup signal.
  */
-int NET_Timeout(JNIEnv *env, int s, long timeout, long nanoTimeStamp) {
+int NET_Timeout0(int s, long timeout, long currentTime) {
+    long prevtime = currentTime, newtime;
     struct timeval t, *tp = &t;
     fd_set fds;
     fd_set* fdsp = NULL;
@@ -461,8 +460,6 @@
     }
     FD_SET(s, fdsp);
 
-    long prevNanoTime = nanoTimeStamp;
-    long nanoTimeout = timeout * NET_NSEC_PER_MSEC;
     for(;;) {
         int rv;
 
@@ -480,21 +477,25 @@
          * has expired return 0 (indicating timeout expired).
          */
         if (rv < 0 && errno == EINTR) {
-            long newNanoTime = JVM_NanoTime(env, 0);
-            nanoTimeout -= newNanoTime - prevNanoTime;
-            if (nanoTimeout < NET_NSEC_PER_MSEC) {
-                if (allocated != 0)
-                    free(fdsp);
-                return 0;
+            if (timeout > 0) {
+                struct timeval now;
+                gettimeofday(&now, NULL);
+                newtime = now.tv_sec * 1000  +  now.tv_usec / 1000;
+                timeout -= newtime - prevtime;
+                if (timeout <= 0) {
+                    if (allocated != 0)
+                        free(fdsp);
+                    return 0;
+                }
+                prevtime = newtime;
+                t.tv_sec = timeout / 1000;
+                t.tv_usec = (timeout % 1000) * 1000;
             }
-            prevNanoTime = newNanoTime;
-            t.tv_sec = nanoTimeout / NET_NSEC_PER_SEC;
-            t.tv_usec = (nanoTimeout % NET_NSEC_PER_SEC) / NET_NSEC_PER_USEC;
-
         } else {
             if (allocated != 0)
                 free(fdsp);
             return rv;
         }
+
     }
 }
--- a/jdk/src/java.base/solaris/native/libnet/solaris_close.c	Wed May 03 09:04:35 2017 -0700
+++ b/jdk/src/java.base/solaris/native/libnet/solaris_close.c	Thu May 04 18:13:42 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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,8 +27,6 @@
 #include <sys/socket.h>
 #include <stropts.h>
 #include <unistd.h>
-#include "jvm.h"
-#include "net_util.h"
 
 /* Support for restartable system calls on Solaris. */
 
@@ -92,22 +90,25 @@
     RESTARTABLE_RETURN_INT(poll(ufds, nfds, timeout));
 }
 
-int NET_Timeout(JNIEnv *env, int s, long timeout, long nanoTimeStamp) {
+int NET_Timeout0(int s, long timeout, long currentTime) {
     int result;
-    long prevNanoTime = nanoTimeStamp;
-    long nanoTimeout = timeout * NET_NSEC_PER_MSEC;
+    struct timeval t;
+    long prevtime = currentTime, newtime;
     struct pollfd pfd;
     pfd.fd = s;
     pfd.events = POLLIN;
 
     for(;;) {
-        result = poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
+        result = poll(&pfd, 1, timeout);
         if (result < 0 && errno == EINTR) {
-            long newNanoTime = JVM_NanoTime(env, 0);
-            nanoTimeout -= newNanoTime - prevNanoTime;
-            if (nanoTimeout < NET_NSEC_PER_MSEC)
-                return 0;
-            prevNanoTime = newNanoTime;
+            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;
+            }
         } else {
             return result;
         }
--- a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Wed May 03 09:04:35 2017 -0700
+++ b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Thu May 04 18:13:42 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -485,7 +485,7 @@
         return -1;
     }
     if (timeout) {
-        int ret = NET_Timeout(env, fd, timeout, JVM_NanoTime(env, 0));
+        int ret = NET_Timeout(fd, timeout);
         if (ret == 0) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Peek timed out");
@@ -576,7 +576,7 @@
     packetBufferOffset = (*env)->GetIntField(env, packet, dp_offsetID);
     packetBufferLen = (*env)->GetIntField(env, packet, dp_bufLengthID);
     if (timeout) {
-        int ret = NET_Timeout(env, fd, timeout, JVM_NanoTime(env, 0));
+        int ret = NET_Timeout(fd, timeout);
         if (ret == 0) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Receive timed out");
@@ -789,7 +789,7 @@
         retry = JNI_FALSE;
 
         if (timeout) {
-            int ret = NET_Timeout(env, fd, timeout, JVM_NanoTime(env, 0));
+            int ret = NET_Timeout(fd, timeout);
             if (ret <= 0) {
                 if (ret == 0) {
                     JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
--- a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c	Wed May 03 09:04:35 2017 -0700
+++ b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c	Thu May 04 18:13:42 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -24,7 +24,6 @@
  */
 #include <errno.h>
 
-#include "jvm.h"
 #include "net_util.h"
 
 #include "java_net_SocketOptions.h"
@@ -232,6 +231,7 @@
 {
     jint localport = (*env)->GetIntField(env, this, psi_localportID);
     int len = 0;
+
     /* fdObj is the FileDescriptor field on this */
     jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
 
@@ -325,8 +325,8 @@
         /* connection not established immediately */
         if (connect_rv != 0) {
             socklen_t optlen;
-            jlong nanoTimeout = timeout * NET_NSEC_PER_MSEC;
-            jlong prevNanoTime = JVM_NanoTime(env, 0);
+            jlong prevTime = JVM_CurrentTimeMillis(env, 0);
+
             if (errno != EINPROGRESS) {
                 NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
                              "connect failed");
@@ -341,13 +341,13 @@
              * this thread.
              */
             while (1) {
-                jlong newNanoTime;
+                jlong newTime;
                 struct pollfd pfd;
                 pfd.fd = fd;
                 pfd.events = POLLOUT;
 
                 errno = 0;
-                connect_rv = NET_Poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
+                connect_rv = NET_Poll(&pfd, 1, timeout);
 
                 if (connect_rv >= 0) {
                     break;
@@ -360,13 +360,13 @@
                  * The poll was interrupted so adjust timeout and
                  * restart
                  */
-                newNanoTime = JVM_NanoTime(env, 0);
-                nanoTimeout -= (newNanoTime - prevNanoTime);
-                if (nanoTimeout < NET_NSEC_PER_MSEC) {
+                newTime = JVM_CurrentTimeMillis(env, 0);
+                timeout -= (newTime - prevTime);
+                if (timeout <= 0) {
                     connect_rv = 0;
                     break;
                 }
-                prevNanoTime = newNanoTime;
+                prevTime = newTime;
 
             } /* while */
 
@@ -593,7 +593,7 @@
     /* fields on this */
     int port;
     jint timeout = (*env)->GetIntField(env, this, psi_timeoutID);
-    jlong prevNanoTime = 0, nanoTimeout = timeout * NET_NSEC_PER_MSEC;
+    jlong prevTime = 0;
     jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
 
     /* the FileDescriptor field on socket */
@@ -633,18 +633,18 @@
      */
     for (;;) {
         int ret;
-        jlong currNanoTime;
+
         /* first usage pick up current time */
-        if (prevNanoTime == 0 && nanoTimeout > 0) {
-            prevNanoTime = JVM_NanoTime(env, 0);
+        if (prevTime == 0 && timeout > 0) {
+            prevTime = JVM_CurrentTimeMillis(env, 0);
         }
 
         /* passing a timeout of 0 to poll will return immediately,
            but in the case of ServerSocket 0 means infinite. */
         if (timeout <= 0) {
-            ret = NET_Timeout(env, fd, -1, 0);
+            ret = NET_Timeout(fd, -1);
         } else {
-            ret = NET_Timeout(env, fd, nanoTimeout / NET_NSEC_PER_MSEC, prevNanoTime);
+            ret = NET_Timeout(fd, timeout);
         }
         if (ret == 0) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
@@ -676,14 +676,17 @@
         }
 
         /* ECONNABORTED or EWOULDBLOCK error so adjust timeout if there is one. */
-        currNanoTime = JVM_NanoTime(env, 0);
-        nanoTimeout -= (currNanoTime - prevNanoTime);
-        if (nanoTimeout < NET_NSEC_PER_MSEC) {
-            JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
-                    "Accept timed out");
-            return;
+        if (timeout) {
+            jlong currTime = JVM_CurrentTimeMillis(env, 0);
+            timeout -= (currTime - prevTime);
+
+            if (timeout <= 0) {
+                JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
+                                "Accept timed out");
+                return;
+            }
+            prevTime = currTime;
         }
-        prevNanoTime = currNanoTime;
     }
 
     if (newfd < 0) {
--- a/jdk/src/java.base/unix/native/libnet/SocketInputStream.c	Wed May 03 09:04:35 2017 -0700
+++ b/jdk/src/java.base/unix/native/libnet/SocketInputStream.c	Thu May 04 18:13:42 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -26,7 +26,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "jvm.h"
 #include "net_util.h"
 
 #include "java_net_SocketInputStream.h"
@@ -49,10 +48,9 @@
 
 static int NET_ReadWithTimeout(JNIEnv *env, int fd, char *bufP, int len, long timeout) {
     int result = 0;
-    long prevNanoTime = JVM_NanoTime(env, 0);
-    long nanoTimeout = timeout * NET_NSEC_PER_MSEC;
-    while (nanoTimeout > NET_NSEC_PER_MSEC) {
-        result = NET_Timeout(env, fd, nanoTimeout / NET_NSEC_PER_MSEC, prevNanoTime);
+    long prevtime = NET_GetCurrentTime(), newtime;
+    while (timeout > 0) {
+        result = NET_TimeoutWithCurrentTime(fd, timeout, prevtime);
         if (result <= 0) {
             if (result == 0) {
                 JNU_ThrowByName(env, "java/net/SocketTimeoutException", "Read timed out");
@@ -70,10 +68,10 @@
         }
         result = NET_NonBlockingRead(fd, bufP, len);
         if (result == -1 && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) {
-            long newtNanoTime = JVM_NanoTime(env, 0);
-            nanoTimeout -= newtNanoTime - prevNanoTime;
-            if (nanoTimeout >= NET_NSEC_PER_MSEC) {
-                prevNanoTime = newtNanoTime;
+            newtime = NET_GetCurrentTime();
+            timeout -= newtime - prevtime;
+            if (timeout > 0) {
+                prevtime = newtime;
             }
         } else {
             break;
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.c	Wed May 03 09:04:35 2017 -0700
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c	Thu May 04 18:13:42 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -49,7 +49,6 @@
 #include <sys/sysctl.h>
 #endif
 
-#include "jvm.h"
 #include "net_util.h"
 
 #include "java_net_SocketOptions.h"
@@ -1544,12 +1543,11 @@
 jint
 NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
 {
-    jlong prevNanoTime = JVM_NanoTime(env, 0);
-    jlong nanoTimeout = timeout * NET_NSEC_PER_MSEC;
+    jlong prevTime = JVM_CurrentTimeMillis(env, 0);
     jint read_rv;
 
     while (1) {
-        jlong newNanoTime;
+        jlong newTime;
         struct pollfd pfd;
         pfd.fd = fd;
         pfd.events = 0;
@@ -1561,18 +1559,36 @@
           pfd.events |= POLLOUT;
 
         errno = 0;
-        read_rv = NET_Poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
+        read_rv = NET_Poll(&pfd, 1, timeout);
 
-        newNanoTime = JVM_NanoTime(env, 0);
-        nanoTimeout -= (newNanoTime - prevNanoTime);
-        if (nanoTimeout < NET_NSEC_PER_MSEC) {
+        newTime = JVM_CurrentTimeMillis(env, 0);
+        timeout -= (newTime - prevTime);
+        if (timeout <= 0) {
           return read_rv > 0 ? 0 : -1;
         }
-        prevNanoTime = newNanoTime;
+        prevTime = newTime;
 
         if (read_rv > 0) {
           break;
         }
+
+
       } /* while */
-    return (nanoTimeout / NET_NSEC_PER_MSEC);
+
+    return timeout;
 }
+
+long NET_GetCurrentTime() {
+    struct timeval time;
+    gettimeofday(&time, NULL);
+    return (time.tv_sec * 1000 + time.tv_usec / 1000);
+}
+
+int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime) {
+    return NET_Timeout0(s, timeout, currentTime);
+}
+
+int NET_Timeout(int s, long timeout) {
+    long currentTime = (timeout > 0) ? NET_GetCurrentTime() : 0;
+    return NET_Timeout0(s, timeout, currentTime);
+}
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.h	Wed May 03 09:04:35 2017 -0700
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.h	Thu May 04 18:13:42 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -34,10 +34,6 @@
  * Macros and constants
  */
 
-#define NET_NSEC_PER_MSEC 1000*1000
-#define NET_NSEC_PER_SEC  1000*1000*1000
-#define NET_NSEC_PER_USEC 1000
-
 /* Defines SO_REUSEPORT */
 #ifndef SO_REUSEPORT
 #ifdef __linux__
@@ -72,9 +68,12 @@
  * Functions
  */
 
-int NET_Timeout(JNIEnv *env, int s, long timeout, long  nanoTimeStamp);
+int NET_Timeout(int s, long timeout);
+int NET_Timeout0(int s, long timeout, long currentTime);
 int NET_Read(int s, void* buf, size_t len);
 int NET_NonBlockingRead(int s, void* buf, size_t len);
+int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime);
+long NET_GetCurrentTime();
 int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
                  struct sockaddr *from, socklen_t *fromlen);
 int NET_ReadV(int s, const struct iovec * vector, int count);