From b9c66ea380130d6bfd6df95d1c779516c651e04e Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Thu, 13 Mar 2014 00:14:44 +0100 Subject: [PATCH] Bump SSHD version to 0.10.1 and enable nio2 backend 46f8488a78742799a4f5f781279c8955460e7964 removed nio2 backend because of a bug [1]. Given that the bug is fixed and released, enable it again. Another problem was also fixed and released [2]. Upgrade to the official version 0.10.1 makes Gerrit's own custom patch of SSHD and hosting it on Google bucket unnecessary. [1] https://issues.apache.org/jira/browse/SSHD-252 [2] https://issues.apache.org/jira/browse/SSHD-255 Bug: Issue 2406 Change-Id: I6668f6194427f153e1982e14b3936d2f3132fa7d --- Documentation/config-gerrit.txt | 8 ++++++++ .../com/google/gerrit/sshd/SshDaemon.java | 18 +++++++++++++----- lib/mina/BUCK | 19 +++++++++---------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt index 038d946e05..ff97fb7c4e 100644 --- a/Documentation/config-gerrit.txt +++ b/Documentation/config-gerrit.txt @@ -2609,6 +2609,14 @@ namespace. To alias `replication start` to `gerrit replicate`: [[sshd]] Section sshd ~~~~~~~~~~~~~~~~~~~~~ +[[sshd.backend]]sshd.backend:: ++ +Starting from version 0.9.0 Apache SSHD project added support for NIO2 +IoSession. To use the new NIO2 session the `backend` option must be set +to `NIO2`. ++ +By default, `MINA`. + [[sshd.listenAddress]]sshd.listenAddress:: + Specifies the local addresses the internal SSHD should listen diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshDaemon.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshDaemon.java index 4f6ccc030d..d6365e082e 100644 --- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshDaemon.java +++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshDaemon.java @@ -61,10 +61,11 @@ import org.apache.sshd.common.forward.TcpipServerChannel; import org.apache.sshd.common.future.CloseFuture; import org.apache.sshd.common.future.SshFutureListener; import org.apache.sshd.common.io.IoAcceptor; -import org.apache.sshd.common.io.IoServiceFactory; +import org.apache.sshd.common.io.IoServiceFactoryFactory; import org.apache.sshd.common.io.IoSession; -import org.apache.sshd.common.io.mina.MinaServiceFactory; +import org.apache.sshd.common.io.mina.MinaServiceFactoryFactory; import org.apache.sshd.common.io.mina.MinaSession; +import org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory; import org.apache.sshd.common.mac.HMACMD5; import org.apache.sshd.common.mac.HMACMD596; import org.apache.sshd.common.mac.HMACSHA1; @@ -184,8 +185,13 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener { final String kerberosPrincipal = cfg.getString( "sshd", null, "kerberosPrincipal"); - System.setProperty(IoServiceFactory.class.getName(), - MinaServiceFactory.class.getName()); + SshSessionBackend backend = cfg.getEnum( + "sshd", null, "backend", SshSessionBackend.MINA); + + System.setProperty(IoServiceFactoryFactory.class.getName(), + backend == SshSessionBackend.MINA + ? MinaServiceFactoryFactory.class.getName() + : Nio2ServiceFactoryFactory.class.getName()); if (SecurityUtils.isBouncyCastleRegistered()) { initProviderBouncyCastle(); @@ -280,8 +286,10 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener { public synchronized void stop() { if (acceptor != null) { try { - acceptor.dispose(); + acceptor.close(true).await(); log.info("Stopped Gerrit SSHD"); + } catch (InterruptedException e) { + log.warn("Exception caught while closing", e); } finally { acceptor = null; } diff --git a/lib/mina/BUCK b/lib/mina/BUCK index 9467cc4a9b..a3577c2da0 100644 --- a/lib/mina/BUCK +++ b/lib/mina/BUCK @@ -6,6 +6,15 @@ EXCLUDE = [ 'META-INF/NOTICE', ] +maven_jar( + name = 'sshd', + id = 'org.apache.sshd:sshd-core:0.10.1', + sha1 = '0081c09917f35565d762c886758dfbdfa1069679', + license = 'Apache2.0', + deps = [':core'], + exclude = EXCLUDE, +) + maven_jar( name = 'core', id = 'org.apache.mina:mina-core:2.0.7', @@ -13,13 +22,3 @@ maven_jar( license = 'Apache2.0', exclude = EXCLUDE, ) - -maven_jar( - name = 'sshd', - id = 'org.apache.sshd:sshd-core:0.9.0.201311081', - sha1 = '38f7ac8602e70fa05fdc6147d204198e9cefe5bc', - license = 'Apache2.0', - deps = [':core'], - exclude = EXCLUDE, - repository = GERRIT, -)