< prev index next >

src/java.base/macosx/native/libnet/bsd_close.c

Print this page

        

@@ -369,10 +369,14 @@
 
 int NET_Read(int s, void* buf, size_t len) {
     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) );
 }
 
 int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,

@@ -408,12 +412,12 @@
 /*
  * Wrapper for select(s, timeout). We are using select() on Mac OS due to Bug 7131399.
  * 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, *tp = &t;
     fd_set fds;
     fd_set* fdsp = NULL;
     int allocated = 0;
     threadEntry_t self;

@@ -430,13 +434,10 @@
     /*
      * Pick up current time as may need to adjust timeout
      */
     if (timeout > 0) {
         /* Timed */
-        struct timeval now;
-        gettimeofday(&now, NULL);
-        prevtime = now.tv_sec * 1000  +  now.tv_usec / 1000;
         t.tv_sec = timeout / 1000;
         t.tv_usec = (timeout % 1000) * 1000;
     } else if (timeout < 0) {
         /* Blocking */
         tp = 0;

@@ -496,5 +497,19 @@
             return rv;
         }
 
     }
 }
+
+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);
+}
< prev index next >