From f421875b4e7b988c75672e40fcf72e67dc722e51 Mon Sep 17 00:00:00 2001 From: bpb Date: Thu, 30 Oct 2014 11:31:17 -0700 Subject: [PATCH] 8062501: Modifications of server socket channel accept() methods for instrumentation purposes Summary: Wrap accept0() native methods in Java accept(). Reviewed-by: chegar, alanb --- .../sun/nio/ch/ServerSocketChannelImpl.java | 14 +++++++++++++- .../UnixAsynchronousServerSocketChannelImpl.java | 16 ++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java b/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java index db73c725c..ee5ff7675 100644 --- a/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java +++ b/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java @@ -247,7 +247,7 @@ class ServerSocketChannelImpl 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 @@ class ServerSocketChannelImpl 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 diff --git a/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java b/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java index 871f19448..8c7cfd229 100644 --- a/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java +++ b/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java @@ -141,7 +141,7 @@ class UnixAsynchronousServerSocketChannelImpl 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 @@ class UnixAsynchronousServerSocketChannelImpl 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 @@ class UnixAsynchronousServerSocketChannelImpl } } + /** + * 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(); -- GitLab