mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 15:20:54 +03:00
change transport layer to use millisecond timeouts
This commit is contained in:
@@ -63,7 +63,7 @@ public class ConnectionImpl
|
||||
*/
|
||||
public ConnectionImpl(Transport trans) {
|
||||
super("ssh-connection", trans);
|
||||
timeoutMs = trans.getTimeout() * 1000;
|
||||
timeoutMs = trans.getTimeoutMs();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -155,7 +155,7 @@ final class KeyExchanger
|
||||
* @param waitForDone whether should block till key exchange completed
|
||||
*
|
||||
* @throws TransportException if there is an error during key exchange
|
||||
* @see {@link Transport#setTimeout} for setting timeout for kex
|
||||
* @see {@link Transport#setTimeoutMs} for setting timeout for kex
|
||||
*/
|
||||
void startKex(boolean waitForDone)
|
||||
throws TransportException {
|
||||
@@ -169,7 +169,7 @@ final class KeyExchanger
|
||||
|
||||
void waitForDone()
|
||||
throws TransportException {
|
||||
done.await(transport.getTimeout(), TimeUnit.SECONDS);
|
||||
done.await(transport.getTimeoutMs(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private synchronized void ensureKexOngoing()
|
||||
@@ -360,7 +360,7 @@ final class KeyExchanger
|
||||
* We block on this event to prevent a race condition where we may have received a SSH_MSG_KEXINIT before
|
||||
* having sent the packet ourselves (would cause gotKexInit() to fail)
|
||||
*/
|
||||
kexInitSent.await(transport.getTimeout(), TimeUnit.SECONDS);
|
||||
kexInitSent.await(transport.getTimeoutMs(), TimeUnit.MILLISECONDS);
|
||||
gotKexInit(buf);
|
||||
expected = Expected.FOLLOWUP;
|
||||
break;
|
||||
|
||||
@@ -86,14 +86,14 @@ public interface Transport
|
||||
Config getConfig();
|
||||
|
||||
/** @return the timeout that is currently set for blocking operations. */
|
||||
int getTimeout();
|
||||
int getTimeoutMs();
|
||||
|
||||
/**
|
||||
* Set a timeout for methods that may block.
|
||||
*
|
||||
* @param timeout the timeout in seconds
|
||||
* @param timeout the timeout in milliseconds
|
||||
*/
|
||||
void setTimeout(int timeout);
|
||||
void setTimeoutMs(int timeout);
|
||||
|
||||
/** @return the interval in seconds at which a heartbeat message is sent to the server */
|
||||
int getHeartbeatInterval();
|
||||
|
||||
@@ -113,7 +113,7 @@ public final class TransportImpl
|
||||
/** Client version identification string */
|
||||
private final String clientID;
|
||||
|
||||
private volatile int timeout = 30;
|
||||
private volatile int timeoutMs = 30 * 1000; // Crazy long, but it was the original default
|
||||
|
||||
private volatile boolean authed = false;
|
||||
|
||||
@@ -241,13 +241,13 @@ public final class TransportImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTimeout() {
|
||||
return timeout;
|
||||
public int getTimeoutMs() {
|
||||
return timeoutMs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
public void setTimeoutMs(int timeoutMs) {
|
||||
this.timeoutMs = timeoutMs;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -311,7 +311,7 @@ public final class TransportImpl
|
||||
try {
|
||||
serviceAccept.clear();
|
||||
sendServiceRequest(service.getName());
|
||||
serviceAccept.await(timeout, TimeUnit.SECONDS);
|
||||
serviceAccept.await(timeoutMs, TimeUnit.MILLISECONDS);
|
||||
setService(service);
|
||||
} finally {
|
||||
serviceAccept.unlock();
|
||||
|
||||
Reference in New Issue
Block a user