updates unixdomainchannels
authormichaelm
Mon, 11 Nov 2019 10:38:24 +0000
branchunixdomainchannels
changeset 59003 aaba7cc40951
parent 58988 b88e23c84b23
child 59004 84e08e00c29c
updates
src/java.base/unix/native/libnio/ch/InheritedChannel.c
test/micro/org/openjdk/bench/java/net/SocketChannelCompare.java
--- a/src/java.base/unix/native/libnio/ch/InheritedChannel.c	Fri Nov 08 16:22:21 2019 +0000
+++ b/src/java.base/unix/native/libnio/ch/InheritedChannel.c	Mon Nov 11 10:38:24 2019 +0000
@@ -72,8 +72,10 @@
     socklen_t len = sizeof(SOCKETADDRESS);
     jobject remote_sa = NULL;
 
-    if (sa.sa.sa_family == AF_UNIX) {
-    	remote_sa = NET_SockaddrToUnixAddress(env, &sa);
+    if (getpeername(fd, &sa.sa, &len) == 0) {
+        if (sa.sa.sa_family == AF_UNIX) {
+            remote_sa = NET_SockaddrToUnixAddress(env, &sa);
+        }
     }
     return remote_sa;
 }
@@ -88,7 +90,7 @@
     if (getpeername(fd, &sa.sa, &len) == 0) {
         if (matchFamilyInet(&sa)) {
             NET_SockaddrToInetAddress(env, &sa, (int *)&remote_port);
-	}
+        }
     }
 
     return remote_port;
--- a/test/micro/org/openjdk/bench/java/net/SocketChannelCompare.java	Fri Nov 08 16:22:21 2019 +0000
+++ b/test/micro/org/openjdk/bench/java/net/SocketChannelCompare.java	Mon Nov 11 10:38:24 2019 +0000
@@ -36,6 +36,10 @@
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.openjdk.jmh.annotations.*;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
 
 /**
  * Tests sending a 128 byte message on a second, to a thread which
@@ -159,8 +163,25 @@
             } catch (ClosedChannelException ex) {
                 // shutdown time
             } catch (IOException ioex) {
-		ioex.printStackTrace();
+                ioex.printStackTrace();
             }
         }
     }
+
+    public static void main(String[] args) throws RunnerException {
+        Options opt = new OptionsBuilder()
+                .include(org.openjdk.bench.java.net.SocketChannelCompare.class.getSimpleName())
+                .forks(3)
+                .build();
+
+        new Runner(opt).run();
+
+        opt = new OptionsBuilder()
+                .include(org.openjdk.bench.java.net.SocketChannelCompare.class.getSimpleName())
+                .jvmArgsPrepend("-Djdk.net.useFastTcpLoopback=true")
+                .forks(3)
+                .build();
+
+        new Runner(opt).run();
+    }
 }