change transport layer to use millisecond timeouts

This commit is contained in:
shikhar
2013-03-24 17:36:11 -04:00
parent 6656214803
commit 88a88c5dba
4 changed files with 13 additions and 13 deletions

View File

@@ -63,7 +63,7 @@ public class ConnectionImpl
*/
public ConnectionImpl(Transport trans) {
super("ssh-connection", trans);
timeoutMs = trans.getTimeout() * 1000;
timeoutMs = trans.getTimeoutMs();
}
@Override

View File

@@ -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;

View File

@@ -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();

View File

@@ -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();