Skip to content

Commit

Permalink
Telnet ConnectionManager should clean closed connections, fixes #709 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Oct 14, 2021
1 parent 5eaf519 commit bef9396
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
Expand Up @@ -240,8 +240,6 @@ public void run() {
//housekeep connections
try {
do {
//clean up and close all broken connections
//cleanupBroken();
//clean up closed connections
cleanupClosed();
//check all active connections
Expand All @@ -256,19 +254,6 @@ public void run() {
LOG.log(Level.FINE, "run():: Ran out " + this.toString());
}//run

/*
private void cleanupBroken() {
//cleanup loop
while (!m_BrokenConnections.isEmpty()) {
Connection nextOne = (Connection) m_BrokenConnections.pop();
log.info("cleanupBroken():: Closing broken connection " + nextOne.toString());
//fire logoff event for shell site cleanup , beware could hog the daemon thread
nextOne.processConnectionEvent(new ConnectionEvent(nextOne, ConnectionEvent.CONNECTION_BROKEN));
//close the connection, will be automatically registered as closed
nextOne.close();
}
}//cleanupBroken
*/
private void cleanupClosed() {
if (stopping) {
return;
Expand Down
Expand Up @@ -41,6 +41,7 @@ public interface ShellProvider {
private final Terminal terminal;
private final ShellProvider provider;
private PortListener portListener;
private ConnectionManager connectionManager;
private int port;
private String ip;

Expand Down Expand Up @@ -94,7 +95,7 @@ private void status() {
}

private void start() throws IOException {
ConnectionManager connectionManager = new ConnectionManager(1000, 5 * 60 * 1000, 5 * 60 * 1000, 60 * 1000, null, null, false) {
connectionManager = new ConnectionManager(1000, 5 * 60 * 1000, 5 * 60 * 1000, 60 * 1000, null, null, false) {
@Override
protected Connection createConnection(ThreadGroup threadGroup, ConnectionData newCD) {
return new Connection(threadGroup, newCD) {
Expand Down Expand Up @@ -162,6 +163,7 @@ protected void doClose() throws Exception {
};
}
};
connectionManager.start();
portListener = new PortListener("gogo", port, 10);
portListener.setConnectionManager(connectionManager);
portListener.start();
Expand All @@ -170,6 +172,8 @@ protected void doClose() throws Exception {
private void stop() throws IOException {
portListener.stop();
portListener = null;
connectionManager.stop();
connectionManager = null;
}

}

0 comments on commit bef9396

Please sign in to comment.