src/share/classes/java/net/SocketInputStream.java

Print this page
rev 6099 : [mq]: io-trace

*** 28,37 **** --- 28,39 ---- import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.IOException; import java.nio.channels.FileChannel; + import sun.misc.IoTrace; + import sun.misc.IoTraceContext; import sun.net.ConnectionResetException; /** * This stream extends FileInputStream to implement a * SocketInputStream. Note that this class should <b>NOT</b> be
*** 120,130 **** public int read(byte b[], int off, int length) throws IOException { return read(b, off, length, impl.getTimeout()); } int read(byte b[], int off, int length, int timeout) throws IOException { ! int n; // EOF already encountered if (eof) { return -1; } --- 122,132 ---- public int read(byte b[], int off, int length) throws IOException { return read(b, off, length, impl.getTimeout()); } int read(byte b[], int off, int length, int timeout) throws IOException { ! int n = 0; // EOF already encountered if (eof) { return -1; }
*** 142,151 **** --- 144,154 ---- throw new ArrayIndexOutOfBoundsException(); } boolean gotReset = false; + IoTraceContext traceContext = IoTrace.socketReadBegin(impl.address, impl.port, timeout); // acquire file descriptor and do the read FileDescriptor fd = impl.acquireFD(); try { n = socketRead0(fd, b, off, length, timeout); if (n > 0) {
*** 153,179 **** --- 156,185 ---- } } catch (ConnectionResetException rstExc) { gotReset = true; } finally { impl.releaseFD(); + IoTrace.socketReadEnd(traceContext, n > 0 ? n : 0); } /* * We receive a "connection reset" but there may be bytes still * buffered on the socket */ if (gotReset) { + traceContext = IoTrace.socketReadBegin(impl.address, impl.port, timeout); impl.setConnectionResetPending(); impl.acquireFD(); try { n = socketRead0(fd, b, off, length, timeout); if (n > 0) { return n; } } catch (ConnectionResetException rstExc) { } finally { impl.releaseFD(); + IoTrace.socketReadEnd(traceContext, n > 0 ? n : 0); } } /* * If we get here we are at EOF, the socket has been closed,