summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohann Latocha2011-06-01 13:58:21 +0200
committerJohann Latocha2011-06-01 13:58:21 +0200
commit4e569d5fec319d4fdc95c21bd704fcd321c07305 (patch)
tree86435e8710e2de7b54f5a1f5999c0b899fc6bbe4
parentDefect #809 (diff)
downloadpvs-4e569d5fec319d4fdc95c21bd704fcd321c07305.tar.gz
pvs-4e569d5fec319d4fdc95c21bd704fcd321c07305.tar.xz
pvs-4e569d5fec319d4fdc95c21bd704fcd321c07305.zip
Enhancement #821
-rw-r--r--src/net/pvsListenServer.cpp11
-rw-r--r--src/net/pvsListenServer.h1
-rw-r--r--src/setup.h3
3 files changed, 11 insertions, 4 deletions
diff --git a/src/net/pvsListenServer.cpp b/src/net/pvsListenServer.cpp
index 90c2dfb..1280a92 100644
--- a/src/net/pvsListenServer.cpp
+++ b/src/net/pvsListenServer.cpp
@@ -28,6 +28,7 @@
#include <cassert>
//#define verbose
#include "mcast/McastConfiguration.h"
+#include <QTime>
// Create listener
PVSListenServer::PVSListenServer(int port, int clients)
@@ -123,13 +124,13 @@ bool PVSListenServer::shutdown()
return false;
}
-// timer event, 5 second interval
+// timer event, CLIENT_TIMEOUT interval
void PVSListenServer::timerEvent(QTimerEvent *event)
{
if (!(_clients.empty()))
{
// Check for ping timeout
- time_t refval = time(NULL) - 10;
+ time_t refval = time(NULL) - (CLIENT_TIMEOUT/1000);
for (std::list<PVSClientConnection*>::iterator it = _clients.begin(); it
!= _clients.end(); it++)
{
@@ -140,9 +141,11 @@ void PVSListenServer::timerEvent(QTimerEvent *event)
if (disconnectClient(client))
break; // list was modified, iterator not valid anymore
}
+ qDebug() << client->lastData() << " " << refval;
if (client->lastData() < refval)
{ // ping timeout
- qDebug("Ping timeout for client %s", qPrintable(client->getNameUser()));
+ qDebug("DEBUG: Ping timeout for client %s", qPrintable(client->getNameUser()));
+ qDebug("DEBUG: Timeout was %i last response was %i", refval, client->lastData());
if (disconnectClient(client))
break; // list was modified, iterator not valid anymore
}
@@ -264,7 +267,7 @@ bool PVSListenServer::init()
_fresh = true;
if (_timer != 0)
killTimer( _timer);
- _timer = startTimer(5000);
+ _timer = startTimer(CLIENT_KEEPALIVE);
return true;
}
return false;
diff --git a/src/net/pvsListenServer.h b/src/net/pvsListenServer.h
index ca9977c..99b6e35 100644
--- a/src/net/pvsListenServer.h
+++ b/src/net/pvsListenServer.h
@@ -5,6 +5,7 @@
#include <src/util/consoleLogger.h>
#include <QtNetwork/QSslSocket>
//#include <QtNetwork/QTcpServer>
+#include "../setup.h"
class SslServer;
diff --git a/src/setup.h b/src/setup.h
index 4a21754..879db1c 100644
--- a/src/setup.h
+++ b/src/setup.h
@@ -10,4 +10,7 @@
#define SD_PORT_CONSOLE 3491 // Not really used, Qt just wants a bind
#define SD_PORT_CLIENT 3492 // This is where we expect announcements
+#define CLIENT_KEEPALIVE 5000 // Clients ping rate
+#define CLIENT_TIMEOUT 15000 // Timeout to check if clients are alive
+
#endif