You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2018/02/07 07:58:30 UTC

[2/5] mina-sshd git commit: [SSHD-801] Close TcpipServerChannel gracefully if exception signalled and IOSession is open

[SSHD-801] Close TcpipServerChannel gracefully if exception signalled and IOSession is open


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

Branch: refs/heads/master
Commit: e077dae67546443a66aa4b101f88de3face5b872
Parents: 17331a8
Author: Goldstein Lyor <ly...@c-b4.com>
Authored: Sun Feb 4 16:21:18 2018 +0200
Committer: Goldstein Lyor <ly...@c-b4.com>
Committed: Wed Feb 7 09:41:25 2018 +0200

----------------------------------------------------------------------
 .../apache/sshd/server/forward/TcpipServerChannel.java    | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/e077dae6/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
index b333170..2c16478 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
@@ -158,8 +158,8 @@ public class TcpipServerChannel extends AbstractServerChannel {
         // TODO: revisit for better threading. Use async io ?
         out = new ChannelOutputStream(this, getRemoteWindow(), log, SshConstants.SSH_MSG_CHANNEL_DATA, true);
         IoHandler handler = new IoHandler() {
-            @SuppressWarnings("synthetic-access")
             @Override
+            @SuppressWarnings("synthetic-access")
             public void messageReceived(IoSession session, Readable message) throws Exception {
                 if (isClosing()) {
                     if (log.isDebugEnabled()) {
@@ -184,8 +184,14 @@ public class TcpipServerChannel extends AbstractServerChannel {
             }
 
             @Override
+            @SuppressWarnings("synthetic-access")
             public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
-                close(true);
+                boolean immediately = !session.isOpen();
+                if (log.isDebugEnabled()) {
+                    log.debug("exceptionCaught({}) signal close immediately={} due to {}[{}]",
+                            TcpipServerChannel.this, immediately, cause.getClass().getSimpleName(), cause.getMessage());
+                }
+                close(immediately);
             }
         };