Fix for correct handling of pending socket connection requests

p4#: 21759
This commit is contained in:
Magne Sjaastad 2013-05-29 10:07:35 +02:00
parent 389247c17e
commit 1519ad0ad1
2 changed files with 23 additions and 12 deletions

View File

@ -129,11 +129,7 @@ void RiaSocketServer::slotNewClientConnection()
} }
} }
handlePendingIncomingConnectionRequests();
// Get the first pending connection, and set it as the current Client to handle
QTcpSocket *newClient = m_tcpServer->nextPendingConnection();
this->handleClientConnection(newClient);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -236,11 +232,14 @@ void RiaSocketServer::readCommandFromOctave()
{ {
delete m_currentCommand; delete m_currentCommand;
m_currentCommand = NULL; m_currentCommand = NULL;
handlePendingIncomingConnectionRequests();
return;
} }
} }
else else
{ {
// Todo: When all commands are into new shape, do the "unknown command" error output here. handlePendingIncomingConnectionRequests();
m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("Unknown command: %1").arg(args[0].data())); m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("Unknown command: %1").arg(args[0].data()));
terminateCurrentConnection(); terminateCurrentConnection();
@ -268,12 +267,7 @@ void RiaSocketServer::slotCurrentClientDisconnected()
terminateCurrentConnection(); terminateCurrentConnection();
QTcpSocket *newClient = m_tcpServer->nextPendingConnection(); handlePendingIncomingConnectionRequests();
if (newClient)
{
this->handleClientConnection(newClient);
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -312,6 +306,8 @@ void RiaSocketServer::slotReadyRead()
{ {
delete m_currentCommand; delete m_currentCommand;
m_currentCommand = NULL; m_currentCommand = NULL;
handlePendingIncomingConnectionRequests();
} }
} }
else else
@ -336,3 +332,17 @@ int RiaSocketServer::currentCaseId() const
return m_currentCaseId; return m_currentCaseId;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSocketServer::handlePendingIncomingConnectionRequests()
{
QTcpSocket* newClient = m_tcpServer->nextPendingConnection();
if (newClient)
{
terminateCurrentConnection();
this->handleClientConnection(newClient);
}
}

View File

@ -63,6 +63,7 @@ private:
void handleClientConnection( QTcpSocket* clientToHandle); void handleClientConnection( QTcpSocket* clientToHandle);
void terminateCurrentConnection(); void terminateCurrentConnection();
void readCommandFromOctave(); void readCommandFromOctave();
void handlePendingIncomingConnectionRequests();
private: private:
QTcpServer* m_tcpServer; QTcpServer* m_tcpServer;