SSH: Set keep-alive timer period to connection timeout.

The Qt SDK's Qemu can be so slow that a single packet takes more
than the old fixed value of five seconds for a round trip.

Change-Id: I06f442c3c080fec8d1b1d10bd26e2e27b06e6863
Reviewed-on: http://codereview.qt.nokia.com/854
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
Christian Kandeler
2011-06-28 18:08:12 +02:00
parent c88cf530fe
commit 2101eff1ef

View File

@@ -201,6 +201,7 @@ SshConnectionPrivate::SshConnectionPrivate(SshConnection *conn,
m_socket->setProxy(m_connParams.proxyType == SshConnectionParameters::DefaultProxy m_socket->setProxy(m_connParams.proxyType == SshConnectionParameters::DefaultProxy
? QNetworkProxy::DefaultProxy : QNetworkProxy::NoProxy); ? QNetworkProxy::DefaultProxy : QNetworkProxy::NoProxy);
m_timeoutTimer.setSingleShot(true); m_timeoutTimer.setSingleShot(true);
m_timeoutTimer.setInterval(m_connParams.timeout * 1000);
m_keepAliveTimer.setSingleShot(true); m_keepAliveTimer.setSingleShot(true);
m_keepAliveTimer.setInterval(10000); m_keepAliveTimer.setInterval(10000);
connect(m_channelManager, SIGNAL(timeout()), this, SLOT(handleTimeout())); connect(m_channelManager, SIGNAL(timeout()), this, SLOT(handleTimeout()));
@@ -614,7 +615,7 @@ void SshConnectionPrivate::sendKeepAlivePacket()
Q_ASSERT(m_lastInvalidMsgSeqNr == InvalidSeqNr); Q_ASSERT(m_lastInvalidMsgSeqNr == InvalidSeqNr);
m_lastInvalidMsgSeqNr = m_sendFacility.nextClientSeqNr(); m_lastInvalidMsgSeqNr = m_sendFacility.nextClientSeqNr();
m_sendFacility.sendInvalidPacket(); m_sendFacility.sendInvalidPacket();
m_timeoutTimer.start(5000); m_timeoutTimer.start();
} }
void SshConnectionPrivate::connectToHost() void SshConnectionPrivate::connectToHost()
@@ -634,7 +635,7 @@ void SshConnectionPrivate::connectToHost()
connect(&m_timeoutTimer, SIGNAL(timeout()), this, SLOT(handleTimeout())); connect(&m_timeoutTimer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
m_state = SocketConnecting; m_state = SocketConnecting;
m_keyExchangeState = NoKeyExchange; m_keyExchangeState = NoKeyExchange;
m_timeoutTimer.start(m_connParams.timeout * 1000); m_timeoutTimer.start();
m_socket->connectToHost(m_connParams.host, m_connParams.port); m_socket->connectToHost(m_connParams.host, m_connParams.port);
} }