Repository: mina-sshd
Updated Branches:
  refs/heads/master 3a6aff31f -> cbcda01c3


[SSHD-716] SSHD Reuse of client session for multiple channel connections fails

Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/cbcda01c
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/cbcda01c
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/cbcda01c

Branch: refs/heads/master
Commit: cbcda01c336c0523e5e13254a10262ce30941ea3
Parents: 3a6aff3
Author: Guillaume Nodet <gno...@apache.org>
Authored: Tue Nov 22 19:21:36 2016 +0100
Committer: Guillaume Nodet <gno...@apache.org>
Committed: Tue Nov 22 19:21:36 2016 +0100

----------------------------------------------------------------------
 .../session/helpers/AbstractConnectionService.java       | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/cbcda01c/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
index 60f98e8..eff3b5d 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
@@ -463,8 +463,15 @@ public abstract class AbstractConnectionService<S extends 
AbstractSession>
      * @throws IOException if an error occurs
      */
     public void channelClose(Buffer buffer) throws IOException {
-        Channel channel = getChannel(buffer);
-        channel.handleClose();
+        // Do not use getChannel to avoid the session being closed
+        // if receiving the SSH_MSG_CHANNEL_CLOSE on an already closed channel
+        int recipient = buffer.getInt();
+        Channel channel = channels.get(recipient);
+        if (channel != null) {
+            channel.handleClose();
+        } else {
+            log.warn("Received SSH_MSG_CHANNEL_CLOSE on unknown channel " + 
recipient);
+        }
     }
 
     /**

Reply via email to