You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2013/07/22 21:04:04 UTC
git commit: [SSHD-188] Session timeout doesn't call destroy() from
InvertedShell
Updated Branches:
refs/heads/master d7c21f799 -> 092e05ea4
[SSHD-188] Session timeout doesn't call destroy() from InvertedShell
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/092e05ea
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/092e05ea
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/092e05ea
Branch: refs/heads/master
Commit: 092e05ea4e0b5e7c2a7ca0b3d5d21be96bf459fe
Parents: d7c21f7
Author: Guillaume Nodet <gn...@apache.org>
Authored: Mon Jul 22 21:03:39 2013 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Mon Jul 22 21:03:39 2013 +0200
----------------------------------------------------------------------
.../sshd/client/session/ClientSessionImpl.java | 2 +-
.../sshd/common/session/AbstractSession.java | 2 +-
.../sshd/server/session/ServerSession.java | 2 +-
.../test/java/org/apache/sshd/ServerTest.java | 24 +++++++++++++++++++-
4 files changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/092e05ea/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
index d40173f..1b46efc 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
@@ -302,7 +302,7 @@ public class ClientSessionImpl extends AbstractSession implements ClientSession
int code = buffer.getInt();
String msg = buffer.getString();
log.info("Received SSH_MSG_DISCONNECT (reason={}, msg={})", code, msg);
- close(false);
+ close(true);
break;
}
case SSH_MSG_UNIMPLEMENTED: {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/092e05ea/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
index 456ba40..ad83261 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
@@ -910,7 +910,7 @@ public abstract class AbstractSession implements Session {
WriteFuture f = writePacket(buffer);
f.addListener(new IoFutureListener() {
public void operationComplete(IoFuture future) {
- close(false);
+ close(true);
}
});
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/092e05ea/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
index 6cdf006..35ab197 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
@@ -335,7 +335,7 @@ public class ServerSession extends AbstractSession {
}
private void processIdleTimer() throws IOException {
- disconnect(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR, "User idle has timed out after " + idleTimeout + "ms.");
+ disconnect(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR, "User session has timed out after being idled for " + idleTimeout + "ms.");
}
private void sendServerIdentification() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/092e05ea/sshd-core/src/test/java/org/apache/sshd/ServerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/ServerTest.java b/sshd-core/src/test/java/org/apache/sshd/ServerTest.java
index a5bb9f3..6d17c8e 100644
--- a/sshd-core/src/test/java/org/apache/sshd/ServerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/ServerTest.java
@@ -69,7 +69,7 @@ public class ServerTest {
sshd = SshServer.setUpDefaultServer();
sshd.setPort(port);
sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
- sshd.setShellFactory(new EchoShellFactory());
+ sshd.setShellFactory(new TestEchoShellFactory());
sshd.setPasswordAuthenticator(new BogusPasswordAuthenticator());
sshd.setSessionFactory(new org.apache.sshd.server.session.SessionFactory());
sshd.start();
@@ -145,6 +145,7 @@ public class ServerTest {
@Test
public void testIdleTimeout() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
+ TestEchoShellFactory.TestEchoShell.latch = new CountDownLatch(1);
sshd.getProperties().put(SshServer.IDLE_TIMEOUT, "1000");
sshd.getSessionFactory().addListener(new SessionListener() {
@@ -173,6 +174,7 @@ public class ServerTest {
int res = s.waitFor(ClientSession.CLOSED, 5000);
assertTrue((res & ClientSession.CLOSED) != 0);
assertTrue(latch.await(1, TimeUnit.SECONDS));
+ assertTrue(TestEchoShellFactory.TestEchoShell.latch.await(1, TimeUnit.SECONDS));
}
@Test
@@ -197,8 +199,28 @@ public class ServerTest {
s.close(false);
}
+ public static class TestEchoShellFactory extends EchoShellFactory {
+ @Override
+ public Command create() {
+ return new TestEchoShell();
+ }
+ public static class TestEchoShell extends EchoShell {
+
+ public static CountDownLatch latch = new CountDownLatch(1);
+
+ @Override
+ public void destroy() {
+ if (latch != null) {
+ latch.countDown();
+ }
+ super.destroy();
+ }
+ }
+ }
+
public static void main(String[] args) throws Exception {
SshServer sshd = SshServer.setUpDefaultServer();
+ sshd.getProperties().put(SshServer.IDLE_TIMEOUT, "10000");
sshd.setPort(8001);
sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));