Commit 43869cd4 authored by ck's avatar ck

Maemo: Fix race condition in SSH thread.

parent b89ea6e8
......@@ -51,6 +51,12 @@ MaemoSshThread::MaemoSshThread(const MaemoDeviceConfig &devConf)
{
}
MaemoSshThread::~MaemoSshThread()
{
stop();
wait();
}
void MaemoSshThread::run()
{
try {
......@@ -62,9 +68,14 @@ void MaemoSshThread::run()
void MaemoSshThread::stop()
{
connection()->stop();
m_connection->stop();
}
void MaemoSshThread::setConnection(const MaemoSshConnection::Ptr &connection)
{
m_connection = connection;
emit connectionEstablished();
}
MaemoSshRunner::MaemoSshRunner(const MaemoDeviceConfig &devConf,
const QString &command)
......@@ -74,16 +85,12 @@ MaemoSshRunner::MaemoSshRunner(const MaemoDeviceConfig &devConf,
void MaemoSshRunner::runInternal()
{
m_connection = MaemoInteractiveSshConnection::create(m_devConf);
emit connectionEstablished();
connect(m_connection.data(), SIGNAL(remoteOutput(QString)),
MaemoInteractiveSshConnection::Ptr connection
= MaemoInteractiveSshConnection::create(m_devConf);
setConnection(connection);
connect(connection.data(), SIGNAL(remoteOutput(QString)),
this, SIGNAL(remoteOutput(QString)));
m_connection->runCommand(m_command);
}
MaemoSshConnection::Ptr MaemoSshRunner::connection()
{
return m_connection;
connection->runCommand(m_command);
}
MaemoSshDeployer::MaemoSshDeployer(const MaemoDeviceConfig &devConf,
......@@ -94,16 +101,12 @@ MaemoSshDeployer::MaemoSshDeployer(const MaemoDeviceConfig &devConf,
void MaemoSshDeployer::runInternal()
{
m_connection = MaemoSftpConnection::create(m_devConf);
emit connectionEstablished();
connect(m_connection.data(), SIGNAL(fileCopied(QString)),
MaemoSftpConnection::Ptr connection
= MaemoSftpConnection::create(m_devConf);
setConnection(connection);
connect(connection.data(), SIGNAL(fileCopied(QString)),
this, SIGNAL(fileCopied(QString)));
m_connection->transferFiles(m_filePaths, m_targetDirs);
}
MaemoSshConnection::Ptr MaemoSshDeployer::connection()
{
return m_connection;
connection->transferFiles(m_filePaths, m_targetDirs);
}
} // namespace Internal
......
......@@ -62,6 +62,7 @@ public:
bool hasError() const { return !m_error.isEmpty(); }
void stop();
virtual void run();
~MaemoSshThread();
signals:
void connectionEstablished();
......@@ -69,13 +70,14 @@ signals:
protected:
MaemoSshThread(const MaemoDeviceConfig &devConf);
virtual void runInternal()=0;
void setConnection(const MaemoSshConnection::Ptr &connection);
const MaemoDeviceConfig m_devConf;
private:
virtual MaemoSshConnection::Ptr connection()=0;
QString m_error;
MaemoSshConnection::Ptr m_connection;
};
......@@ -90,11 +92,9 @@ signals:
void remoteOutput(const QString &output);
private:
virtual MaemoSshConnection::Ptr connection();
virtual void runInternal();
const QString m_command;
MaemoInteractiveSshConnection::Ptr m_connection;
};
......@@ -110,12 +110,10 @@ signals:
void fileCopied(const QString &filePath);
private:
virtual MaemoSshConnection::Ptr connection();
virtual void runInternal();
const QStringList m_filePaths;
const QStringList m_targetDirs;
MaemoSftpConnection::Ptr m_connection;
};
} // namespace Internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment