OSDN Git Service

SSH: Don't allow connectToHost() while already connecting/connected.
authorChristian Kandeler <christian.kandeler@nokia.com>
Tue, 5 Jul 2011 16:01:58 +0000 (18:01 +0200)
committerChristian Kandeler <christian.kandeler@nokia.com>
Wed, 6 Jul 2011 11:09:05 +0000 (13:09 +0200)
Also fix callers potentially violating this policy.

Change-Id: I630f1c544885df93a81e217e792363c0c2314108
Reviewed-on: http://codereview.qt.nokia.com/1186
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
src/libs/utils/ssh/sshconnection.cpp
src/libs/utils/ssh/sshremoteprocessrunner.cpp
src/plugins/debugger/gdb/remotegdbprocess.cpp
src/plugins/remotelinux/abstractmaemodeploystep.cpp
src/plugins/remotelinux/remotelinuxapplicationrunner.cpp
src/plugins/valgrind/valgrind/valgrindprocess.cpp

index 6a71281..0efdd00 100644 (file)
@@ -620,6 +620,8 @@ void SshConnectionPrivate::sendKeepAlivePacket()
 
 void SshConnectionPrivate::connectToHost()
 {
+    QTC_ASSERT(m_state == SocketUnconnected, return);
+
     m_incomingData.clear();
     m_incomingPacket.reset();
     m_sendFacility.reset();
index 0d5fa24..6a751cc 100644 (file)
@@ -145,7 +145,8 @@ void SshRemoteProcessRunnerPrivate::run(const QByteArray &command)
     } else {
         connect(m_connection.data(), SIGNAL(connected()),
             SLOT(handleConnected()));
-        m_connection->connectToHost();
+        if (m_connection->state() == SshConnection::Unconnected)
+            m_connection->connectToHost();
     }
 }
 
index f32af66..124e43f 100644 (file)
@@ -98,7 +98,8 @@ void RemoteGdbProcess::realStart(const QString &cmd, const QStringList &args,
         handleConnected();
     } else {
         connect(m_conn.data(), SIGNAL(connected()), this, SLOT(handleConnected()));
-        m_conn->connectToHost();
+        if (m_conn->state() == SshConnection::Unconnected)
+            m_conn->connectToHost();
     }
 }
 
index e305bdc..3275550 100644 (file)
@@ -298,7 +298,8 @@ void AbstractMaemoDeployStep::connectToDevice()
         connect(m_connection.data(), SIGNAL(connected()), this,
             SLOT(handleConnected()));
         writeOutput(tr("Connecting to device..."));
-        m_connection->connectToHost();
+        if (m_connection->state() == SshConnection::Unconnected)
+            m_connection->connectToHost();
     }
 }
 
index 57ecf01..340f415 100644 (file)
@@ -105,7 +105,8 @@ void RemoteLinuxApplicationRunner::start()
         handleConnected();
     } else {
         emit reportProgress(tr("Connecting to device..."));
-        m_connection->connectToHost();
+        if (m_connection->state() == Utils::SshConnection::Unconnected)
+            m_connection->connectToHost();
     }
 }
 
index 2be53c4..b2da555 100644 (file)
@@ -186,7 +186,8 @@ void RemoteValgrindProcess::run(const QString &valgrindExecutable, const QString
                 this, SLOT(connected()));
         connect(m_connection.data(), SIGNAL(error(Utils::SshError)),
                 this, SLOT(error(Utils::SshError)));
-        m_connection->connectToHost();
+        if (m_connection->state() == Utils::SshConnection::Unconnected)
+            m_connection->connectToHost();
     } else {
         connected();
     }