diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt index 975de0ca3c..aa9c7fff12 100644 --- a/Documentation/config-gerrit.txt +++ b/Documentation/config-gerrit.txt @@ -2639,6 +2639,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 6351280881..1969e2d48c 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, -)