mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -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:
@@ -18,6 +18,7 @@
|
|||||||
#include "RiaStdInclude.h"
|
#include "RiaStdInclude.h"
|
||||||
#include "RiaSocketServer.h"
|
#include "RiaSocketServer.h"
|
||||||
#include "RiaSocketCommand.h"
|
#include "RiaSocketCommand.h"
|
||||||
|
#include "RiaSocketTools.h"
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QtNetwork>
|
#include <QtNetwork>
|
||||||
@@ -68,6 +69,10 @@ RiaSocketServer::RiaSocketServer(QObject* parent)
|
|||||||
|
|
||||||
m_tcpServer = new QTcpServer(this);
|
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))
|
if (!m_tcpServer->listen(QHostAddress::LocalHost, 40001))
|
||||||
{
|
{
|
||||||
m_errorMessageDialog->showMessage("Octave communication disabled :\n"
|
m_errorMessageDialog->showMessage("Octave communication disabled :\n"
|
||||||
@@ -81,6 +86,7 @@ RiaSocketServer::RiaSocketServer(QObject* parent)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(m_nextPendingConnectionTimer, SIGNAL(timeout()), this, SLOT(handleNextPendingConnection()));
|
||||||
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(slotNewClientConnection()));
|
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(slotNewClientConnection()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +116,8 @@ void RiaSocketServer::slotNewClientConnection()
|
|||||||
|
|
||||||
if (m_currentClient && (m_currentClient->state() == QAbstractSocket::ConnectedState) )
|
if (m_currentClient && (m_currentClient->state() == QAbstractSocket::ConnectedState) )
|
||||||
{
|
{
|
||||||
|
//PMonLog("Starting Timer");
|
||||||
|
m_nextPendingConnectionTimer->start(); // Reset and start again
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,9 +320,18 @@ void RiaSocketServer::handleNextPendingConnection()
|
|||||||
{
|
{
|
||||||
if (m_currentClient && (m_currentClient->state() == QAbstractSocket::ConnectedState) )
|
if (m_currentClient && (m_currentClient->state() == QAbstractSocket::ConnectedState) )
|
||||||
{
|
{
|
||||||
|
//PMonLog("Starting Timer");
|
||||||
|
m_nextPendingConnectionTimer->start(); // Reset and start again
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stop timer
|
||||||
|
if (m_nextPendingConnectionTimer->isActive())
|
||||||
|
{
|
||||||
|
//PMonLog("Stopping Timer");
|
||||||
|
m_nextPendingConnectionTimer->stop();
|
||||||
|
}
|
||||||
|
|
||||||
terminateCurrentConnection();
|
terminateCurrentConnection();
|
||||||
|
|
||||||
QTcpSocket* clientToHandle = m_tcpServer->nextPendingConnection();
|
QTcpSocket* clientToHandle = m_tcpServer->nextPendingConnection();
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class QTcpServer;
|
|||||||
class QTcpSocket;
|
class QTcpSocket;
|
||||||
class QNetworkSession;
|
class QNetworkSession;
|
||||||
class QErrorMessage;
|
class QErrorMessage;
|
||||||
|
class QTimer;
|
||||||
class RimCase;
|
class RimCase;
|
||||||
class RiaSocketCommand;
|
class RiaSocketCommand;
|
||||||
|
|
||||||
@@ -59,10 +60,11 @@ private slots:
|
|||||||
void slotNewClientConnection();
|
void slotNewClientConnection();
|
||||||
void slotCurrentClientDisconnected();
|
void slotCurrentClientDisconnected();
|
||||||
void slotReadyRead();
|
void slotReadyRead();
|
||||||
|
void handleNextPendingConnection();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void terminateCurrentConnection();
|
void terminateCurrentConnection();
|
||||||
bool readCommandFromOctave();
|
bool readCommandFromOctave();
|
||||||
void handleNextPendingConnection();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTcpServer* m_tcpServer;
|
QTcpServer* m_tcpServer;
|
||||||
@@ -73,5 +75,7 @@ private:
|
|||||||
|
|
||||||
RiaSocketCommand* m_currentCommand;
|
RiaSocketCommand* m_currentCommand;
|
||||||
|
|
||||||
|
QTimer* m_nextPendingConnectionTimer;
|
||||||
|
|
||||||
int m_currentCaseId; // Set to -1 to use default server behavior
|
int m_currentCaseId; // Set to -1 to use default server behavior
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user