Commit 98347316 authored by Ulf Hermann's avatar Ulf Hermann
Browse files

iostool: Allow sequential client connections



The QML debug server allows this and QtCreator uses it, so iostool
should support it, too.

Change-Id: I71d4143457d427795e5abcbef0ad5d26378d5e9d
Task-number: QTCREATORBUG-15383
Reviewed-by: default avatarJake Petroules <jake.petroules@theqtcompany.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 79c27ec6
...@@ -114,6 +114,7 @@ public: ...@@ -114,6 +114,7 @@ public:
IosTool *iosTool(); IosTool *iosTool();
public slots: public slots:
void handleNewRelayConnection(); void handleNewRelayConnection();
void removeRelayConnection(Relayer *relayer);
protected: protected:
virtual void newRelayConnection() = 0; virtual void newRelayConnection() = 0;
...@@ -231,9 +232,12 @@ void Relayer::setClientSocket(QTcpSocket *clientSocket) ...@@ -231,9 +232,12 @@ void Relayer::setClientSocket(QTcpSocket *clientSocket)
{ {
QTC_CHECK(!m_clientSocket); QTC_CHECK(!m_clientSocket);
m_clientSocket = clientSocket; m_clientSocket = clientSocket;
if (m_clientSocket) if (m_clientSocket) {
connect(m_clientSocket, SIGNAL(error(QAbstractSocket::SocketError)), connect(m_clientSocket, SIGNAL(error(QAbstractSocket::SocketError)),
SLOT(handleClientHasError(QAbstractSocket::SocketError))); SLOT(handleClientHasError(QAbstractSocket::SocketError)));
connect(m_clientSocket, &QAbstractSocket::disconnected,
this, [this](){server()->removeRelayConnection(this);});
}
} }
bool Relayer::startRelay(int serverFileDescriptor) bool Relayer::startRelay(int serverFileDescriptor)
...@@ -354,7 +358,7 @@ void Relayer::handleClientHasData() ...@@ -354,7 +358,7 @@ void Relayer::handleClientHasData()
void Relayer::handleClientHasError(QAbstractSocket::SocketError error) void Relayer::handleClientHasError(QAbstractSocket::SocketError error)
{ {
iosTool()->errorMsg(tr("iOS Debugging connection to creator failed with error %1").arg(error)); iosTool()->errorMsg(tr("iOS Debugging connection to creator failed with error %1").arg(error));
iosTool()->stopRelayServers(); server()->removeRelayConnection(this);
} }
IosTool *Relayer::iosTool() IosTool *Relayer::iosTool()
...@@ -446,6 +450,12 @@ void RelayServer::handleNewRelayConnection() ...@@ -446,6 +450,12 @@ void RelayServer::handleNewRelayConnection()
newRelayConnection(); newRelayConnection();
} }
void RelayServer::removeRelayConnection(Relayer *relayer)
{
m_connections.removeAll(relayer);
relayer->deleteLater();
}
SingleRelayServer::SingleRelayServer(IosTool *parent, SingleRelayServer::SingleRelayServer(IosTool *parent,
int serverFileDescriptor) : int serverFileDescriptor) :
RelayServer(parent) RelayServer(parent)
...@@ -458,9 +468,7 @@ SingleRelayServer::SingleRelayServer(IosTool *parent, ...@@ -458,9 +468,7 @@ SingleRelayServer::SingleRelayServer(IosTool *parent,
void SingleRelayServer::newRelayConnection() void SingleRelayServer::newRelayConnection()
{ {
if (m_connections.size() > 0) { if (m_connections.size() > 0) {
m_server.close(); delete m_server.nextPendingConnection();
QTcpSocket *s = m_server.nextPendingConnection();
delete s;
return; return;
} }
QTcpSocket *clientSocket = m_server.nextPendingConnection(); QTcpSocket *clientSocket = m_server.nextPendingConnection();
...@@ -469,7 +477,6 @@ void SingleRelayServer::newRelayConnection() ...@@ -469,7 +477,6 @@ void SingleRelayServer::newRelayConnection()
m_connections.append(newConnection); m_connections.append(newConnection);
newConnection->startRelay(m_serverFileDescriptor); newConnection->startRelay(m_serverFileDescriptor);
} }
m_server.close();
} }
GenericRelayServer::GenericRelayServer(IosTool *parent, int remotePort, GenericRelayServer::GenericRelayServer(IosTool *parent, int remotePort,
......
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