src/share/classes/sun/nio/ch/SocketAdaptor.java
Print this page
rev 5501 : imported patch io-trace
@@ -32,10 +32,12 @@
import java.nio.channels.*;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import java.util.*;
+import sun.misc.IoTrace;
+
// Make a socket channel look like a socket.
//
// The only aspects of java.net.Socket-hood that we don't attempt to emulate
// here are the interrupted-I/O exceptions (which our Solaris implementations
@@ -202,12 +204,13 @@
// Implement timeout with a selector
SelectionKey sk = null;
Selector sel = null;
sc.configureBlocking(false);
+ int n = 0;
+ Object traceContext = IoTrace.socketReadBegin(getInetAddress(), getPort(), timeout);
try {
- int n;
if ((n = sc.read(bb)) != 0)
return n;
sel = Util.getTemporarySelector(sc);
sk = sc.register(sel, SelectionKey.OP_READ);
long to = timeout;
@@ -224,10 +227,11 @@
to -= System.currentTimeMillis() - st;
if (to <= 0)
throw new SocketTimeoutException();
}
} finally {
+ IoTrace.socketReadEnd(traceContext, n > 0 ? n : 0);
if (sk != null)
sk.cancel();
if (sc.isOpen())
sc.configureBlocking(true);
if (sel != null)