forked from qt-creator/qt-creator
SSH: Check for more timeouts.
This commit is contained in:
@@ -34,6 +34,8 @@
|
|||||||
|
|
||||||
#include <botan/exceptn.h>
|
#include <botan/exceptn.h>
|
||||||
|
|
||||||
|
#include <QtCore/QTimer>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -46,10 +48,13 @@ namespace {
|
|||||||
|
|
||||||
AbstractSshChannel::AbstractSshChannel(quint32 channelId,
|
AbstractSshChannel::AbstractSshChannel(quint32 channelId,
|
||||||
SshSendFacility &sendFacility)
|
SshSendFacility &sendFacility)
|
||||||
: m_sendFacility(sendFacility), m_localChannel(channelId),
|
: m_sendFacility(sendFacility), m_timeoutTimer(new QTimer(this)),
|
||||||
m_remoteChannel(NoChannel), m_localWindowSize(InitialWindowSize),
|
m_localChannel(channelId), m_remoteChannel(NoChannel),
|
||||||
m_remoteWindowSize(0), m_state(Inactive)
|
m_localWindowSize(InitialWindowSize), m_remoteWindowSize(0),
|
||||||
|
m_state(Inactive)
|
||||||
{
|
{
|
||||||
|
m_timeoutTimer->setSingleShot(true);
|
||||||
|
connect(m_timeoutTimer, SIGNAL(timeout()), this, SIGNAL(timeout()));
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractSshChannel::~AbstractSshChannel()
|
AbstractSshChannel::~AbstractSshChannel()
|
||||||
@@ -74,6 +79,7 @@ void AbstractSshChannel::requestSessionStart()
|
|||||||
m_sendFacility.sendSessionPacket(m_localChannel, InitialWindowSize,
|
m_sendFacility.sendSessionPacket(m_localChannel, InitialWindowSize,
|
||||||
MaxPacketSize);
|
MaxPacketSize);
|
||||||
setChannelState(SessionRequested);
|
setChannelState(SessionRequested);
|
||||||
|
m_timeoutTimer->start(ReplyTimeout);
|
||||||
} catch (Botan::Exception &e) {
|
} catch (Botan::Exception &e) {
|
||||||
m_errorString = QString::fromAscii(e.what());
|
m_errorString = QString::fromAscii(e.what());
|
||||||
closeChannel();
|
closeChannel();
|
||||||
@@ -124,6 +130,7 @@ void AbstractSshChannel::handleOpenSuccess(quint32 remoteChannelId,
|
|||||||
throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR,
|
throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR,
|
||||||
"Invalid SSH_MSG_CHANNEL_OPEN_CONFIRMATION packet.");
|
"Invalid SSH_MSG_CHANNEL_OPEN_CONFIRMATION packet.");
|
||||||
}
|
}
|
||||||
|
m_timeoutTimer->stop();
|
||||||
|
|
||||||
if (remoteMaxPacketSize < MinMaxPacketSize) {
|
if (remoteMaxPacketSize < MinMaxPacketSize) {
|
||||||
throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR,
|
throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR,
|
||||||
@@ -148,6 +155,7 @@ void AbstractSshChannel::handleOpenFailure(const QString &reason)
|
|||||||
throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR,
|
throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR,
|
||||||
"Invalid SSH_MSG_CHANNEL_OPEN_FAILURE packet.");
|
"Invalid SSH_MSG_CHANNEL_OPEN_FAILURE packet.");
|
||||||
}
|
}
|
||||||
|
m_timeoutTimer->stop();
|
||||||
|
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
#ifdef CREATOR_SSH_DEBUG
|
||||||
qDebug("Channel open request failed for channel %u", m_localChannel);
|
qDebug("Channel open request failed for channel %u", m_localChannel);
|
||||||
@@ -217,13 +225,16 @@ int AbstractSshChannel::handleChannelOrExtendedChannelData(const QByteArray &dat
|
|||||||
|
|
||||||
void AbstractSshChannel::closeChannel()
|
void AbstractSshChannel::closeChannel()
|
||||||
{
|
{
|
||||||
if (m_state != CloseRequested && m_state != Closed) {
|
if (m_state == CloseRequested) {
|
||||||
|
m_timeoutTimer->stop();
|
||||||
|
} else if (m_state != Closed) {
|
||||||
if (m_state == Inactive) {
|
if (m_state == Inactive) {
|
||||||
setChannelState(Closed);
|
setChannelState(Closed);
|
||||||
} else {
|
} else {
|
||||||
setChannelState(CloseRequested);
|
setChannelState(CloseRequested);
|
||||||
m_sendFacility.sendChannelEofPacket(m_remoteChannel);
|
m_sendFacility.sendChannelEofPacket(m_remoteChannel);
|
||||||
m_sendFacility.sendChannelClosePacket(m_remoteChannel);
|
m_sendFacility.sendChannelClosePacket(m_remoteChannel);
|
||||||
|
m_timeoutTimer->start(ReplyTimeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,8 @@
|
|||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QTimer);
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -78,6 +80,8 @@ public:
|
|||||||
|
|
||||||
virtual ~AbstractSshChannel();
|
virtual ~AbstractSshChannel();
|
||||||
|
|
||||||
|
static const int ReplyTimeout = 10000; // milli seconds
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void timeout();
|
void timeout();
|
||||||
|
|
||||||
@@ -88,6 +92,7 @@ protected:
|
|||||||
void checkChannelActive();
|
void checkChannelActive();
|
||||||
|
|
||||||
SshSendFacility &m_sendFacility;
|
SshSendFacility &m_sendFacility;
|
||||||
|
QTimer * const m_timeoutTimer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void handleOpenSuccessInternal()=0;
|
virtual void handleOpenSuccessInternal()=0;
|
||||||
|
@@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
#include <botan/exceptn.h>
|
#include <botan/exceptn.h>
|
||||||
|
|
||||||
|
#include <QtCore/QTimer>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
const QByteArray SshRemoteProcess::AbrtSignal("ABRT");
|
const QByteArray SshRemoteProcess::AbrtSignal("ABRT");
|
||||||
@@ -158,6 +160,7 @@ void SshRemoteProcessPrivate::handleOpenSuccessInternal()
|
|||||||
|
|
||||||
m_sendFacility.sendExecPacket(remoteChannel(), m_command);
|
m_sendFacility.sendExecPacket(remoteChannel(), m_command);
|
||||||
setProcState(ExecRequested);
|
setProcState(ExecRequested);
|
||||||
|
m_timeoutTimer->start(ReplyTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SshRemoteProcessPrivate::handleOpenFailureInternal()
|
void SshRemoteProcessPrivate::handleOpenFailureInternal()
|
||||||
@@ -171,6 +174,7 @@ void SshRemoteProcessPrivate::handleChannelSuccess()
|
|||||||
throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR,
|
throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR,
|
||||||
"Unexpected SSH_MSG_CHANNEL_SUCCESS message.");
|
"Unexpected SSH_MSG_CHANNEL_SUCCESS message.");
|
||||||
}
|
}
|
||||||
|
m_timeoutTimer->stop();
|
||||||
setProcState(Running);
|
setProcState(Running);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +184,7 @@ void SshRemoteProcessPrivate::handleChannelFailure()
|
|||||||
throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR,
|
throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR,
|
||||||
"Unexpected SSH_MSG_CHANNEL_FAILURE message.");
|
"Unexpected SSH_MSG_CHANNEL_FAILURE message.");
|
||||||
}
|
}
|
||||||
|
m_timeoutTimer->stop();
|
||||||
setProcState(StartFailed);
|
setProcState(StartFailed);
|
||||||
closeChannel();
|
closeChannel();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user