Skip to content

Commit

Permalink
JENKINS-7836 tentative fix for the copy from slave to master issues. …
Browse files Browse the repository at this point in the history
…The problem looks similar to JENKINS-7745, so we might as well synchronized the ProxyInputStream.
  • Loading branch information
lacostej committed Feb 3, 2011
1 parent 3ddb68f commit 31b8361
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions remoting/src/main/java/hudson/remoting/ProxyInputStream.java
Expand Up @@ -55,7 +55,7 @@ public ProxyInputStream(Channel channel, int oid) throws IOException {
@Override
public int read() throws IOException {
try {
Buffer buf = new Chunk(oid, 1).call(channel);
Buffer buf = _read(1);
if(buf.len==1)
// byte->int expansion needs to be done carefully becaue byte in Java is signed
// whose idea was it to make byte signed, anyway!?
Expand All @@ -70,10 +70,14 @@ public int read() throws IOException {
}
}

private synchronized Buffer _read(int len) throws IOException, InterruptedException {
return new Chunk(oid, len).call(channel);
}

@Override
public int read(byte b[], int off, int len) throws IOException {
try {
Buffer buf = new Chunk(oid,len).call(channel);
Buffer buf = _read(len);
if(buf.len==-1) return -1;
System.arraycopy(buf.buf,0,b,off,buf.len);
return buf.len;
Expand Down

0 comments on commit 31b8361

Please sign in to comment.