Skip to content

Commit

Permalink
cleankill: added interrupting client listener
Browse files Browse the repository at this point in the history
  • Loading branch information
balihoo-gens committed Mar 24, 2015
1 parent 9e77575 commit 2860161
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ public interface NGClientListener {
* clientDisconnected throws an InterruptedException nailgun interrupts the main session thread.
*/
public void clientDisconnected() throws InterruptedException;

public final class Interrupter implements NGClientListener {
public void clientDisconnected() throws InterruptedException {
throw new InterruptedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@ public void run() {
PrintStream exit = null;

try {
in = new NGInputStream(sockin, sockout, server.out, heartbeatTimeoutMillis);
NGInputStream ngin = new NGInputStream(sockin, sockout, server.out, heartbeatTimeoutMillis);
ngin.addClientListener(new NGClientListener.Interrupter());

in = ngin;
out = new PrintStream(new NGOutputStream(sockout, NGConstants.CHUNKTYPE_STDOUT));
err = new PrintStream(new NGOutputStream(sockout, NGConstants.CHUNKTYPE_STDERR));
exit = new PrintStream(new NGOutputStream(sockout, NGConstants.CHUNKTYPE_EXIT));
Expand Down

0 comments on commit 2860161

Please sign in to comment.