Skip to content

Commit

Permalink
[FIXED JENKINS-8703] we still need to wait for the pipe to connect
Browse files Browse the repository at this point in the history
before letting the writer loose.
  • Loading branch information
kohsuke committed Jul 1, 2011
1 parent 67ce74f commit 0f1ab58
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion remoting/src/main/java/hudson/remoting/Pipe.java
Expand Up @@ -169,7 +169,7 @@ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFound
// we want 'oidRos' to send data to this PipedOutputStream
FastPipedOutputStream pos = new FastPipedOutputStream();
FastPipedInputStream pis = new FastPipedInputStream(pos);
final int oidPos = channel.export(pos);
final int oidPos = channel.export(pos,false); // this gets unexported when the remote ProxyOutputStream closes.

// tell 'ros' to connect to our 'pos'.
channel.send(new ConnectCommand(oidRos, oidPos));
Expand Down
6 changes: 6 additions & 0 deletions remoting/src/main/java/hudson/remoting/PipeWindow.java
Expand Up @@ -126,7 +126,13 @@ public int hashCode() {

static class Real extends PipeWindow {
private int available;
/**
* Total bytes that left our side of the channel.
*/
private long written;
/**
* Total bytes that the remote side acked.
*/
private long acked;
private final int oid;
/**
Expand Down
2 changes: 2 additions & 0 deletions remoting/src/test/java/Driver8703.java
Expand Up @@ -32,8 +32,10 @@ public Object call() throws Exception {
foo();
return null;
} catch (Exception e) {
e.printStackTrace();
throw e;
} catch (Throwable t) {
t.printStackTrace();
throw new Exception(t);
} finally {
Thread.currentThread().setName("done");
Expand Down
3 changes: 3 additions & 0 deletions remoting/src/test/java/hudson/remoting/PipeTest.java
Expand Up @@ -36,6 +36,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.Arrays;
import java.util.concurrent.ExecutionException;

Expand Down Expand Up @@ -175,6 +176,8 @@ public void run() {

// make sure the pipe is connected
target.ensureConnected();
channel.syncLocalIO();
// then let the writer commence
writer.start();

// make sure that some data arrived to the receiver
Expand Down

0 comments on commit 0f1ab58

Please sign in to comment.