summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.ssh.apache
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-04-28 00:21:16 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2019-04-28 00:30:47 +0200
commit32f0963b84b8e40d05f683752d6cec3c94d07279 (patch)
tree56ac47686fd6685109bc91363b30b4be56d4958b /org.eclipse.jgit.ssh.apache
parentc23ccd29b5269e68aa23cbbba30b1b2df521e81f (diff)
parenta72e0b0188376c72d153d0e6fc784952274870ae (diff)
downloadjgit-32f0963b84b8e40d05f683752d6cec3c94d07279.tar.gz
jgit-32f0963b84b8e40d05f683752d6cec3c94d07279.zip
Merge branch 'stable-5.2' into stable-5.3
* stable-5.2: Prepare 5.2.3-SNAPSHOT builds JGit v5.2.2.201904231744-r Revert 4678f4b and provide another solution for bug 467631 Apache MINA sshd: make sendKexInit() work also for re-keying Prepare 5.1.8-SNAPSHOT builds JGit v5.1.7.201904200442-r ObjectUploadListener: Add callback interface Prepare 4.11.9-SNAPSHOT builds JGit v4.11.8.201904181247-r Prepare 4.9.11-SNAPSHOT builds JGit v4.9.10.201904181027-r Prepare 4.7.10-SNAPSHOT builds JGit v4.7.9.201904161809-r Prepare 4.5.8-SNAPSHOT builds JGit v4.5.7.201904151645-r Remember the cause for invalidating a packfile Fix API problem filters Fix pack files scan when filesnapshot isn't modified Change-Id: Ie7e572ac7e346f21fe0c387d7448be168a9c127a Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.ssh.apache')
-rw-r--r--org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java47
-rw-r--r--org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/AbstractClientProxyConnector.java20
-rw-r--r--org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/StatefulProxyConnector.java9
3 files changed, 44 insertions, 32 deletions
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java
index 9b4694c450..dcf330a2a4 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java
@@ -149,10 +149,27 @@ public class JGitClientSession extends ClientSessionImpl {
@Override
protected IoWriteFuture sendIdentification(String ident)
throws IOException {
- // Nothing; we do this below together with the KEX init in
- // sendStartSsh(). Called only from the ClientSessionImpl constructor,
- // where the return value is ignored.
- return null;
+ StatefulProxyConnector proxy = proxyHandler;
+ if (proxy != null) {
+ try {
+ // We must not block here; the framework starts reading messages
+ // from the peer only once the initial sendKexInit() following
+ // this call to sendIdentification() has returned!
+ proxy.runWhenDone(() -> {
+ JGitClientSession.super.sendIdentification(ident);
+ return null;
+ });
+ // Called only from the ClientSessionImpl constructor, where the
+ // return value is ignored.
+ return null;
+ } catch (IOException e) {
+ throw e;
+ } catch (Exception other) {
+ throw new IOException(other.getLocalizedMessage(), other);
+ }
+ } else {
+ return super.sendIdentification(ident);
+ }
}
@Override
@@ -161,12 +178,13 @@ public class JGitClientSession extends ClientSessionImpl {
if (proxy != null) {
try {
// We must not block here; the framework starts reading messages
- // from the peer only once sendKexInit() has returned!
+ // from the peer only once the initial sendKexInit() has
+ // returned!
proxy.runWhenDone(() -> {
- sendStartSsh();
+ JGitClientSession.super.sendKexInit();
return null;
});
- // sendKexInit() is called only from the ClientSessionImpl
+ // This is called only from the ClientSessionImpl
// constructor, where the return value is ignored.
return null;
} catch (IOException e) {
@@ -175,24 +193,11 @@ public class JGitClientSession extends ClientSessionImpl {
throw new IOException(other.getLocalizedMessage(), other);
}
} else {
- return sendStartSsh();
+ return super.sendKexInit();
}
}
/**
- * Sends the initial messages starting the ssh setup: the client
- * identification and the KEX init message.
- *
- * @return the client's KEX seed
- * @throws IOException
- * if something goes wrong
- */
- private byte[] sendStartSsh() throws IOException {
- super.sendIdentification(clientVersion);
- return super.sendKexInit();
- }
-
- /**
* {@inheritDoc}
*
* As long as we're still setting up the proxy connection, diverts messages
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/AbstractClientProxyConnector.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/AbstractClientProxyConnector.java
index 444fbb62ed..2e87c57332 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/AbstractClientProxyConnector.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/AbstractClientProxyConnector.java
@@ -43,7 +43,9 @@
package org.eclipse.jgit.internal.transport.sshd.proxy;
import java.net.InetSocketAddress;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
@@ -61,12 +63,12 @@ public abstract class AbstractClientProxyConnector
private static final long DEFAULT_PROXY_TIMEOUT_MILLIS = TimeUnit.SECONDS
.toMillis(30L);
- /** Guards {@link #done} and {@link #startSsh}. */
+ /** Guards {@link #done} and {@link #bufferedCommands}. */
private Object lock = new Object();
private boolean done;
- private Callable<Void> startSsh;
+ private List<Callable<Void>> bufferedCommands = new ArrayList<>();
private AtomicReference<Runnable> unregister = new AtomicReference<>();
@@ -173,18 +175,20 @@ public abstract class AbstractClientProxyConnector
* if starting ssh fails
*/
protected void setDone(boolean success) throws Exception {
- Callable<Void> starter;
+ List<Callable<Void>> buffered;
Runnable unset = unregister.getAndSet(null);
if (unset != null) {
unset.run();
}
synchronized (lock) {
done = true;
- starter = startSsh;
- startSsh = null;
+ buffered = bufferedCommands;
+ bufferedCommands = null;
}
- if (success && starter != null) {
- starter.call();
+ if (success && buffered != null) {
+ for (Callable<Void> starter : buffered) {
+ starter.call();
+ }
}
}
@@ -192,7 +196,7 @@ public abstract class AbstractClientProxyConnector
public void runWhenDone(Callable<Void> starter) throws Exception {
synchronized (lock) {
if (!done) {
- this.startSsh = starter;
+ bufferedCommands.add(starter);
return;
}
}
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/StatefulProxyConnector.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/StatefulProxyConnector.java
index 0d8e0f93e5..6bd836a587 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/StatefulProxyConnector.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/StatefulProxyConnector.java
@@ -78,12 +78,15 @@ public interface StatefulProxyConnector extends ClientProxyConnector {
void messageReceived(IoSession session, Readable buffer) throws Exception;
/**
- * Runs {@code startSsh} once the proxy connection is established.
+ * Runs {@code command} once the proxy connection is established. May be
+ * called multiple times; commands are run sequentially. If the proxy
+ * connection is already established, {@code command} is executed directly
+ * synchronously.
*
- * @param startSsh
+ * @param command
* operation to run
* @throws Exception
* if the operation is run synchronously and throws an exception
*/
- void runWhenDone(Callable<Void> startSsh) throws Exception;
+ void runWhenDone(Callable<Void> command) throws Exception;
}