mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-01 03:37:15 -06:00
Octave Interface: Tentative Fix of lockup of Resinsight
Added a timer to call back if a signal from the socket has to be ignored. This way we should not loose signals and state. Needs to be experienced over some time to be verified.
This commit is contained in:
parent
d5fe84bfbb
commit
606a14f9f7
@ -18,6 +18,7 @@
|
||||
#include "RiaStdInclude.h"
|
||||
#include "RiaSocketServer.h"
|
||||
#include "RiaSocketCommand.h"
|
||||
#include "RiaSocketTools.h"
|
||||
|
||||
#include <QtGui>
|
||||
#include <QtNetwork>
|
||||
@ -68,6 +69,10 @@ RiaSocketServer::RiaSocketServer(QObject* parent)
|
||||
|
||||
m_tcpServer = new QTcpServer(this);
|
||||
|
||||
m_nextPendingConnectionTimer = new QTimer(this);
|
||||
m_nextPendingConnectionTimer->setInterval(100);
|
||||
m_nextPendingConnectionTimer->setSingleShot(true);
|
||||
|
||||
if (!m_tcpServer->listen(QHostAddress::LocalHost, 40001))
|
||||
{
|
||||
m_errorMessageDialog->showMessage("Octave communication disabled :\n"
|
||||
@ -81,6 +86,7 @@ RiaSocketServer::RiaSocketServer(QObject* parent)
|
||||
return;
|
||||
}
|
||||
|
||||
connect(m_nextPendingConnectionTimer, SIGNAL(timeout()), this, SLOT(handleNextPendingConnection()));
|
||||
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(slotNewClientConnection()));
|
||||
}
|
||||
|
||||
@ -110,6 +116,8 @@ void RiaSocketServer::slotNewClientConnection()
|
||||
|
||||
if (m_currentClient && (m_currentClient->state() == QAbstractSocket::ConnectedState) )
|
||||
{
|
||||
//PMonLog("Starting Timer");
|
||||
m_nextPendingConnectionTimer->start(); // Reset and start again
|
||||
return;
|
||||
}
|
||||
|
||||
@ -312,9 +320,18 @@ void RiaSocketServer::handleNextPendingConnection()
|
||||
{
|
||||
if (m_currentClient && (m_currentClient->state() == QAbstractSocket::ConnectedState) )
|
||||
{
|
||||
//PMonLog("Starting Timer");
|
||||
m_nextPendingConnectionTimer->start(); // Reset and start again
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop timer
|
||||
if (m_nextPendingConnectionTimer->isActive())
|
||||
{
|
||||
//PMonLog("Stopping Timer");
|
||||
m_nextPendingConnectionTimer->stop();
|
||||
}
|
||||
|
||||
terminateCurrentConnection();
|
||||
|
||||
QTcpSocket* clientToHandle = m_tcpServer->nextPendingConnection();
|
||||
|
@ -28,6 +28,7 @@ class QTcpServer;
|
||||
class QTcpSocket;
|
||||
class QNetworkSession;
|
||||
class QErrorMessage;
|
||||
class QTimer;
|
||||
class RimCase;
|
||||
class RiaSocketCommand;
|
||||
|
||||
@ -59,10 +60,11 @@ private slots:
|
||||
void slotNewClientConnection();
|
||||
void slotCurrentClientDisconnected();
|
||||
void slotReadyRead();
|
||||
void handleNextPendingConnection();
|
||||
|
||||
private:
|
||||
void terminateCurrentConnection();
|
||||
bool readCommandFromOctave();
|
||||
void handleNextPendingConnection();
|
||||
|
||||
private:
|
||||
QTcpServer* m_tcpServer;
|
||||
@ -73,5 +75,7 @@ private:
|
||||
|
||||
RiaSocketCommand* m_currentCommand;
|
||||
|
||||
QTimer* m_nextPendingConnectionTimer;
|
||||
|
||||
int m_currentCaseId; // Set to -1 to use default server behavior
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user