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 2014/10/16 23:19:15 UTC

[7/8] git commit: [SSHD-348] Some SSH threads get blocked in Object.wait() method forever

[SSHD-348] Some SSH threads get blocked in Object.wait() method forever


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

Branch: refs/heads/master
Commit: 016afc4fd189b2eba93bbd05bf02989ce20f7ec7
Parents: d838664
Author: Guillaume Nodet <gn...@apache.org>
Authored: Thu Oct 16 22:48:36 2014 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Thu Oct 16 22:57:29 2014 +0200

----------------------------------------------------------------------
 .../sshd/common/session/AbstractConnectionService.java    | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/016afc4f/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
index 6bd467d..0ffed33 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
@@ -113,12 +113,14 @@ public abstract class AbstractConnectionService extends CloseableUtils.AbstractI
      * @throws IOException
      */
     public int registerChannel(Channel channel) throws IOException {
-        if (isClosing()) {
-            throw new IllegalStateException("Session is being closed");
-        }
         int channelId = getNextChannelId();
         channel.init(this, session, channelId);
-        channels.put(channelId, channel);
+        synchronized (lock) {
+            if (isClosing()) {
+                throw new IllegalStateException("Session is being closed");
+            }
+            channels.put(channelId, channel);
+        }
         return channelId;
     }