forked from qt-creator/qt-creator
SSH: Don't use socket if it's in an unhealthy state.
This commit is contained in:
@@ -241,6 +241,8 @@ void SshConnectionPrivate::handleIncomingData()
|
||||
return; // For stuff queued in the event loop after we've called closeConnection();
|
||||
|
||||
try {
|
||||
if (!canUseSocket())
|
||||
return;
|
||||
m_incomingData += m_socket->readAll();
|
||||
#ifdef CREATOR_SSH_DEBUG
|
||||
qDebug("state = %d, remote data size = %d", m_state,
|
||||
@@ -478,6 +480,7 @@ void SshConnectionPrivate::handleDisconnect()
|
||||
|
||||
void SshConnectionPrivate::sendData(const QByteArray &data)
|
||||
{
|
||||
if (canUseSocket())
|
||||
m_socket->write(data);
|
||||
}
|
||||
|
||||
@@ -543,10 +546,17 @@ void SshConnectionPrivate::closeConnection(SshErrorCode sshError,
|
||||
emit error(userError);
|
||||
if (m_state == ConnectionEstablished)
|
||||
emit disconnected();
|
||||
if (canUseSocket())
|
||||
m_socket->disconnectFromHost();
|
||||
m_state = SocketUnconnected;
|
||||
}
|
||||
|
||||
bool SshConnectionPrivate::canUseSocket() const
|
||||
{
|
||||
return m_socket->isValid()
|
||||
&& m_socket->state() == QAbstractSocket::ConnectedState;
|
||||
}
|
||||
|
||||
QSharedPointer<SshRemoteProcess> SshConnectionPrivate::createRemoteProcess(const QByteArray &command)
|
||||
{
|
||||
return m_channelManager->createRemoteProcess(command);
|
||||
|
@@ -124,6 +124,7 @@ private:
|
||||
void handleChannelEof();
|
||||
void handleChannelClose();
|
||||
void handleDisconnect();
|
||||
bool canUseSocket() const;
|
||||
|
||||
void sendData(const QByteArray &data);
|
||||
|
||||
|
@@ -48,8 +48,11 @@ void SshSendFacility::sendPacket()
|
||||
#ifdef CREATOR_SSH_DEBUG
|
||||
qDebug("Sending packet, client seq nr is %u", m_clientSeqNr);
|
||||
#endif
|
||||
if (m_socket->isValid()
|
||||
&& m_socket->state() == QAbstractSocket::ConnectedState) {
|
||||
m_socket->write(m_outgoingPacket.rawData());
|
||||
++m_clientSeqNr;
|
||||
}
|
||||
}
|
||||
|
||||
void SshSendFacility::reset()
|
||||
|
Reference in New Issue
Block a user