Maemo: Better reporting of SSH timeouts, additional unmount step.

This commit is contained in:
Christian Kandeler
2010-08-17 10:47:36 +02:00
parent 2c5e3f1f69
commit 90dea9d645
7 changed files with 57 additions and 30 deletions

View File

@@ -234,7 +234,6 @@ void AbstractSshChannel::closeChannel()
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);
} }
} }
} }

View File

@@ -406,6 +406,7 @@ void SshConnectionPrivate::handleUserAuthSuccessPacket()
void SshConnectionPrivate::handleUserAuthFailurePacket() void SshConnectionPrivate::handleUserAuthFailurePacket()
{ {
m_timeoutTimer.stop();
const QString errorMsg = m_connParams.authType == SshConnectionParameters::AuthByPwd const QString errorMsg = m_connParams.authType == SshConnectionParameters::AuthByPwd
? tr("Server rejected password.") : tr("Server rejected key."); ? tr("Server rejected password.") : tr("Server rejected key.");
throw SshClientException(SshAuthenticationError, errorMsg); throw SshClientException(SshAuthenticationError, errorMsg);

View File

@@ -195,6 +195,7 @@ const MaemoPackageCreationStep *MaemoDeployStep::packagingStep() const
void MaemoDeployStep::raiseError(const QString &errorString) void MaemoDeployStep::raiseError(const QString &errorString)
{ {
disconnect(m_connection.data(), 0, this, 0);
emit addTask(Task(Task::Error, errorString, QString(), -1, emit addTask(Task(Task::Error, errorString, QString(), -1,
Constants::TASK_CATEGORY_BUILDSYSTEM)); Constants::TASK_CATEGORY_BUILDSYSTEM));
emit error(); emit error();

View File

@@ -83,6 +83,7 @@ public:
const MaemoDeployable &deployable) const; const MaemoDeployable &deployable) const;
void setDeployed(const QString &host, const MaemoDeployable &deployable); void setDeployed(const QString &host, const MaemoDeployable &deployable);
MaemoDeployables *deployables() const { return m_deployables; } MaemoDeployables *deployables() const { return m_deployables; }
QSharedPointer<Core::SshConnection> sshConnection() const { return m_connection; }
signals: signals:
void done(); void done();

View File

@@ -145,9 +145,9 @@ bool MaemoRunControl::isRunning() const
void MaemoRunControl::handleError(const QString &errString) void MaemoRunControl::handleError(const QString &errString)
{ {
QMessageBox::critical(0, tr("Remote Execution Failure"), errString);
emit appendMessage(this, errString, true);
stop(); stop();
emit appendMessage(this, errString, true);
QMessageBox::critical(0, tr("Remote Execution Failure"), errString);
} }
void MaemoRunControl::setFinished() void MaemoRunControl::setFinished()

View File

@@ -34,6 +34,7 @@
#include "maemosshrunner.h" #include "maemosshrunner.h"
#include "maemodeploystep.h"
#include "maemodeviceconfigurations.h" #include "maemodeviceconfigurations.h"
#include "maemoglobal.h" #include "maemoglobal.h"
#include "maemoremotemounter.h" #include "maemoremotemounter.h"
@@ -89,9 +90,10 @@ void MaemoSshRunner::start()
m_exitStatus = -1; m_exitStatus = -1;
if (m_connection) if (m_connection)
disconnect(m_connection.data(), 0, this, 0); disconnect(m_connection.data(), 0, this, 0);
const bool reUse = m_connection bool reUse = isConnectionUsable();
&& m_connection->state() == SshConnection::Connected if (!reUse)
&& m_connection->connectionParameters() == m_devConfig.server; m_connection = m_runConfig->deployStep()->sshConnection();
reUse = isConnectionUsable();
if (!reUse) if (!reUse)
m_connection = SshConnection::create(); m_connection = SshConnection::create();
connect(m_connection.data(), SIGNAL(connected()), this, connect(m_connection.data(), SIGNAL(connected()), this,
@@ -112,7 +114,6 @@ void MaemoSshRunner::stop()
return; return;
m_stop = true; m_stop = true;
disconnect(m_connection.data(), 0, this, 0);
m_mounter->stop(); m_mounter->stop();
if (m_cleaner) if (m_cleaner)
disconnect(m_cleaner.data(), 0, this, 0); disconnect(m_cleaner.data(), 0, this, 0);
@@ -135,6 +136,9 @@ void MaemoSshRunner::handleConnectionFailure()
void MaemoSshRunner::cleanup(bool initialCleanup) void MaemoSshRunner::cleanup(bool initialCleanup)
{ {
if (!isConnectionUsable())
return;
emit reportProgress(tr("Killing remote process(es)...")); emit reportProgress(tr("Killing remote process(es)..."));
m_shuttingDown = !initialCleanup; m_shuttingDown = !initialCleanup;
QString niceKill; QString niceKill;
@@ -159,6 +163,7 @@ void MaemoSshRunner::handleCleanupFinished(int exitStatus)
|| exitStatus == SshRemoteProcess::ExitedNormally); || exitStatus == SshRemoteProcess::ExitedNormally);
if (m_shuttingDown) { if (m_shuttingDown) {
m_unmountState = ShutdownUnmount;
m_mounter->unmount(); m_mounter->unmount();
return; return;
} }
@@ -171,29 +176,17 @@ void MaemoSshRunner::handleCleanupFinished(int exitStatus)
.arg(m_cleaner->errorString())); .arg(m_cleaner->errorString()));
} else { } else {
m_mounter->setConnection(m_connection); m_mounter->setConnection(m_connection);
m_unmountState = InitialUnmount;
m_mounter->unmount(); m_mounter->unmount();
} }
} }
void MaemoSshRunner::handleUnmounted() void MaemoSshRunner::handleUnmounted()
{ {
if (m_shuttingDown) { switch (m_unmountState) {
m_shuttingDown = false; case InitialUnmount: {
if (m_exitStatus == SshRemoteProcess::ExitedNormally) {
emit remoteProcessFinished(m_runner->exitCode());
} else if (m_exitStatus == -1) {
emit remoteProcessFinished(-1);
} else {
emit error(tr("Error running remote process: %1")
.arg(m_runner->errorString()));
}
m_exitStatus = -1;
return;
}
if (m_stop) if (m_stop)
return; return;
MaemoPortList portList = m_devConfig.freePorts(); MaemoPortList portList = m_devConfig.freePorts();
if (m_debugging && !m_runConfig->useRemoteGdb()) if (m_debugging && !m_runConfig->useRemoteGdb())
portList.getNext(); // One has already been used for gdbserver. portList.getNext(); // One has already been used for gdbserver.
@@ -210,7 +203,29 @@ void MaemoSshRunner::handleUnmounted()
MaemoGlobal::remoteProjectSourcesMountPoint()))) MaemoGlobal::remoteProjectSourcesMountPoint())))
return; return;
} }
m_unmountState = PreMountUnmount;
m_mounter->unmount();
break;
}
case PreMountUnmount:
if (m_stop)
return;
m_mounter->mount(); m_mounter->mount();
break;
case ShutdownUnmount:
Q_ASSERT(m_shuttingDown);
m_shuttingDown = false;
if (m_exitStatus == SshRemoteProcess::ExitedNormally) {
emit remoteProcessFinished(m_runner->exitCode());
} else if (m_exitStatus == -1) {
emit remoteProcessFinished(-1);
} else {
emit error(tr("Error running remote process: %1")
.arg(m_runner->errorString()));
}
m_exitStatus = -1;
break;
}
} }
void MaemoSshRunner::handleMounted() void MaemoSshRunner::handleMounted()
@@ -265,6 +280,12 @@ bool MaemoSshRunner::addMountSpecification(const MaemoMountSpecification &mountS
return true; return true;
} }
bool MaemoSshRunner::isConnectionUsable() const
{
return m_connection && m_connection->state() == SshConnection::Connected
&& m_connection->connectionParameters() == m_devConfig.server;
}
} // namespace Internal } // namespace Internal
} // namespace Qt4ProjectManager } // namespace Qt4ProjectManager

View File

@@ -90,6 +90,7 @@ private slots:
private: private:
void cleanup(bool initialCleanup); void cleanup(bool initialCleanup);
bool addMountSpecification(const MaemoMountSpecification &mountSpec); bool addMountSpecification(const MaemoMountSpecification &mountSpec);
bool isConnectionUsable() const;
MaemoRunConfiguration * const m_runConfig; // TODO this pointer can be invalid MaemoRunConfiguration * const m_runConfig; // TODO this pointer can be invalid
MaemoRemoteMounter * const m_mounter; MaemoRemoteMounter * const m_mounter;
@@ -104,6 +105,9 @@ private:
int m_exitStatus; int m_exitStatus;
bool m_shuttingDown; bool m_shuttingDown;
const bool m_debugging; const bool m_debugging;
enum UnmountState { InitialUnmount, PreMountUnmount, ShutdownUnmount };
UnmountState m_unmountState;
}; };
} // namespace Internal } // namespace Internal