Skip to content

Commit

Permalink
Merge pull request #2 from balihoo/11417-KillThreadOnClientDisconnect
Browse files Browse the repository at this point in the history
cleankill: added interrupting client listener
  • Loading branch information
denji committed Jul 13, 2015
2 parents 5c33d6e + 2860161 commit f9adcc3
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 @@ -255,7 +255,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 f9adcc3

Please sign in to comment.