Skip to content

Commit

Permalink
refs SoftwareAG#5 try to use connection timeout at kex wait
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Gaydamaka committed Mar 14, 2022
1 parent e5f331a commit 6631436
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/main/java/ch/ethz/ssh2/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ public void run() {

/* Wait until first KEX has finished */

ConnectionInfo ci = tm.getConnectionInfo(1);
ConnectionInfo ci = tm.getConnectionInfo(1, connectTimeout);

/* Now try to cancel the timeout, if needed */

Expand Down Expand Up @@ -926,7 +926,7 @@ public synchronized int getPort() {
public synchronized ConnectionInfo getConnectionInfo() throws IOException {
this.checkConnection();

return tm.getConnectionInfo(1);
return tm.getConnectionInfo(1, 0);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ch/ethz/ssh2/ServerConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public synchronized void connect(int timeout_milliseconds) throws IOException

/* Wait until first KEX has finished */

state.tm.getConnectionInfo(1);
state.tm.getConnectionInfo(1, timeout_milliseconds);
}

/**
Expand Down Expand Up @@ -192,7 +192,7 @@ public synchronized ConnectionInfo getConnectionInfo() throws IOException
"Cannot get details of connection, you need to start the key exchange first.");
}

return state.tm.getConnectionInfo(1);
return state.tm.getConnectionInfo(1, 0);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ch/ethz/ssh2/transport/KexManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public KexManager(TransportManager tm, ClientServerHello csh, CryptoWishList ini
this.rnd = rnd;
}

public ConnectionInfo getOrWaitForConnectionInfo(int minKexCount) throws IOException
public ConnectionInfo getOrWaitForConnectionInfo(int minKexCount, int timeoutMs) throws IOException
{
synchronized (accessLock)
{
Expand All @@ -77,7 +77,7 @@ public ConnectionInfo getOrWaitForConnectionInfo(int minKexCount) throws IOExcep

try
{
accessLock.wait();
accessLock.wait(timeoutMs);
}
catch (InterruptedException e)
{
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ch/ethz/ssh2/transport/TransportManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ public int getPacketOverheadEstimate() {
return tc.getPacketOverheadEstimate();
}

public ConnectionInfo getConnectionInfo(int kexNumber) throws IOException {
return km.getOrWaitForConnectionInfo(kexNumber);
public ConnectionInfo getConnectionInfo(int kexNumber, int timeoutMs) throws IOException {
return km.getOrWaitForConnectionInfo(kexNumber, timeoutMs);
}

public Throwable getReasonClosedCause() {
Expand Down

0 comments on commit 6631436

Please sign in to comment.