src/share/classes/java/net/SocketInputStream.java
Print this page
rev 6052 : [mq]: jdk.patch
*** 28,37 ****
--- 28,38 ----
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
+ import sun.misc.IoTrace;
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;
}
--- 121,131 ----
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 ****
--- 143,153 ----
throw new ArrayIndexOutOfBoundsException();
}
boolean gotReset = false;
+ Object traceHandle = 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 ****
--- 155,184 ----
}
} catch (ConnectionResetException rstExc) {
gotReset = true;
} finally {
impl.releaseFD();
+ IoTrace.socketReadEnd(traceHandle, n);
}
/*
* We receive a "connection reset" but there may be bytes still
* buffered on the socket
*/
if (gotReset) {
+ traceHandle = 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(traceHandle, n);
}
}
/*
* If we get here we are at EOF, the socket has been closed,