Skip to content

Feature 5 Endless wait at KexManager #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.gradle
build
.idea
gradlew
gradlew.bat
gradle
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