8062501: Modifications of server socket channel accept() methods for instrumentation purposes
authorbpb
Thu, 30 Oct 2014 11:31:17 -0700
changeset 27300 c4394453e952
parent 27299 9055eec8eef6
child 27301 f86bf2fa3e02
8062501: Modifications of server socket channel accept() methods for instrumentation purposes Summary: Wrap accept0() native methods in Java accept(). Reviewed-by: chegar, alanb
jdk/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java
jdk/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java
--- a/jdk/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java	Thu Oct 30 07:30:33 2014 -0700
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java	Thu Oct 30 11:31:17 2014 -0700
@@ -247,7 +247,7 @@
                     return null;
                 thread = NativeThread.current();
                 for (;;) {
-                    n = accept0(this.fd, newfd, isaa);
+                    n = accept(this.fd, newfd, isaa);
                     if ((n == IOStatus.INTERRUPTED) && isOpen())
                         continue;
                     break;
@@ -410,6 +410,18 @@
         return sb.toString();
     }
 
+    /**
+     * Accept a connection on a socket.
+     *
+     * @implNote Wrap native call to allow instrumentation.
+     */
+    private int accept(FileDescriptor ssfd, FileDescriptor newfd,
+                       InetSocketAddress[] isaa)
+        throws IOException
+    {
+        return accept0(ssfd, newfd, isaa);
+    }
+
     // -- Native methods --
 
     // Accepts a new connection, setting the given file descriptor to refer to
--- a/jdk/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java	Thu Oct 30 07:30:33 2014 -0700
+++ b/jdk/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java	Thu Oct 30 11:31:17 2014 -0700
@@ -141,7 +141,7 @@
         Throwable exc = null;
         try {
             begin();
-            int n = accept0(this.fd, newfd, isaa);
+            int n = accept(this.fd, newfd, isaa);
 
             // spurious wakeup, is this possible?
             if (n == IOStatus.UNAVAILABLE) {
@@ -277,7 +277,7 @@
         try {
             begin();
 
-            int n = accept0(this.fd, newfd, isaa);
+            int n = accept(this.fd, newfd, isaa);
             if (n == IOStatus.UNAVAILABLE) {
 
                 // need calling context when there is security manager as
@@ -332,6 +332,18 @@
         }
     }
 
+    /**
+     * Accept a connection on a socket.
+     *
+     * @implNote Wrap native call to allow instrumentation.
+     */
+    private int accept(FileDescriptor ssfd, FileDescriptor newfd,
+                       InetSocketAddress[] isaa)
+        throws IOException
+    {
+        return accept0(ssfd, newfd, isaa);
+    }
+
     // -- Native methods --
 
     private static native void initIDs();