Updated pingClockTimeout to account for adjustments in client keep alive settings value.

Changed the default value for the client keep alive variable back to 1 (since that is what the setting is if the value is not found in the configuration ini file).
This commit is contained in:
woogerboy21 2015-07-30 16:38:02 -04:00
parent 8c7301b19f
commit eb9ca58fd0
5 changed files with 102 additions and 92 deletions

View file

@ -56,6 +56,7 @@ public:
virtual QString getLoginMessage() const { return QString(); } virtual QString getLoginMessage() const { return QString(); }
virtual bool getGameShouldPing() const { return false; } virtual bool getGameShouldPing() const { return false; }
virtual int getPingClockInterval() const { return 0; }
virtual int getMaxGameInactivityTime() const { return 9999999; } virtual int getMaxGameInactivityTime() const { return 9999999; }
virtual int getMaxPlayerInactivityTime() const { return 9999999; } virtual int getMaxPlayerInactivityTime() const { return 9999999; }
virtual int getMessageCountingInterval() const { return 0; } virtual int getMessageCountingInterval() const { return 0; }

View file

@ -342,21 +342,30 @@ void Server_ProtocolHandler::processCommandContainer(const CommandContainer &con
void Server_ProtocolHandler::pingClockTimeout() void Server_ProtocolHandler::pingClockTimeout()
{ {
int cmdcountinterval = server->getCommandCountingInterval();
int msgcountinterval = server->getMessageCountingInterval();
int pingclockinterval = server->getPingClockInterval();
int interval = server->getMessageCountingInterval(); int interval = server->getMessageCountingInterval();
if (interval > 0) { if (interval > 0) {
messageSizeOverTime.prepend(0); if(pingclockinterval > 0) {
if (messageSizeOverTime.size() > server->getMessageCountingInterval()) messageSizeOverTime.prepend(0);
messageSizeOverTime.removeLast(); if (messageSizeOverTime.size() > (msgcountinterval / pingclockinterval))
messageCountOverTime.prepend(0); messageSizeOverTime.removeLast();
if (messageCountOverTime.size() > server->getMessageCountingInterval()) messageCountOverTime.prepend(0);
messageCountOverTime.removeLast(); if (messageCountOverTime.size() > (msgcountinterval / pingclockinterval))
messageCountOverTime.removeLast();
}
} }
interval = server->getCommandCountingInterval(); interval = server->getCommandCountingInterval();
if (interval > 0) { if (interval > 0) {
commandCountOverTime.prepend(0); if (pingclockinterval > 0) {
if (commandCountOverTime.size() > server->getCommandCountingInterval()) commandCountOverTime.prepend(0);
commandCountOverTime.removeLast(); if (commandCountOverTime.size() > (cmdcountinterval / pingclockinterval))
commandCountOverTime.removeLast();
}
} }
if (timeRunning - lastDataReceived > server->getMaxPlayerInactivityTime()) if (timeRunning - lastDataReceived > server->getMaxPlayerInactivityTime())

View file

@ -39,8 +39,8 @@ logfile=server.log
logfilters="" logfilters=""
; Set the time interval in seconds that servatrice will use to communicate with each connected client ; Set the time interval in seconds that servatrice will use to communicate with each connected client
; to verify the client has not timed out. Defaults is 5 seconds ; to verify the client has not timed out. Defaults is 1 seconds
clientkeepalive=5 clientkeepalive=1
; Maximum time in seconds a player can stay inactive with there client not even responding to pings, before is ; Maximum time in seconds a player can stay inactive with there client not even responding to pings, before is
; considered disconnected; default is 15 ; considered disconnected; default is 15

View file

@ -274,7 +274,7 @@ bool Servatrice::initServer()
maxGameInactivityTime = settingsCache->value("game/max_game_inactivity_time", 120).toInt(); maxGameInactivityTime = settingsCache->value("game/max_game_inactivity_time", 120).toInt();
maxPlayerInactivityTime = settingsCache->value("server/max_player_inactivity_time", 15).toInt(); maxPlayerInactivityTime = settingsCache->value("server/max_player_inactivity_time", 15).toInt();
pingClockInterval = settingsCache->value("server/clientkeepalive", 1).toInt();
maxUsersPerAddress = settingsCache->value("security/max_users_per_address", 4).toInt(); maxUsersPerAddress = settingsCache->value("security/max_users_per_address", 4).toInt();
messageCountingInterval = settingsCache->value("security/message_counting_interval", 10).toInt(); messageCountingInterval = settingsCache->value("security/message_counting_interval", 10).toInt();
maxMessageCountPerInterval = settingsCache->value("security/max_message_count_per_interval", 15).toInt(); maxMessageCountPerInterval = settingsCache->value("security/max_message_count_per_interval", 15).toInt();
@ -343,10 +343,9 @@ bool Servatrice::initServer()
return false; return false;
} }
int clientkeepalive = settingsCache->value("server/clientkeepalive", 1).toInt();
pingClock = new QTimer(this); pingClock = new QTimer(this);
connect(pingClock, SIGNAL(timeout()), this, SIGNAL(pingClockTimeout())); connect(pingClock, SIGNAL(timeout()), this, SIGNAL(pingClockTimeout()));
pingClock->start(clientkeepalive * 1000); pingClock->start(pingClockInterval * 1000);
int statusUpdateTime = settingsCache->value("server/statusupdate", 15000).toInt(); int statusUpdateTime = settingsCache->value("server/statusupdate", 15000).toInt();
statusUpdateClock = new QTimer(this); statusUpdateClock = new QTimer(this);

View file

@ -115,7 +115,7 @@ private:
QMutex txBytesMutex, rxBytesMutex; QMutex txBytesMutex, rxBytesMutex;
quint64 txBytes, rxBytes; quint64 txBytes, rxBytes;
int maxGameInactivityTime, maxPlayerInactivityTime; int maxGameInactivityTime, maxPlayerInactivityTime;
int maxUsersPerAddress, messageCountingInterval, maxMessageCountPerInterval, maxMessageSizePerInterval, maxGamesPerUser, commandCountingInterval, maxCommandCountPerInterval; int maxUsersPerAddress, messageCountingInterval, maxMessageCountPerInterval, maxMessageSizePerInterval, maxGamesPerUser, commandCountingInterval, maxCommandCountPerInterval, pingClockInterval;
QString shutdownReason; QString shutdownReason;
int shutdownMinutes; int shutdownMinutes;
@ -137,6 +137,7 @@ public:
QString getServerName() const { return serverName; } QString getServerName() const { return serverName; }
QString getLoginMessage() const { QMutexLocker locker(&loginMessageMutex); return loginMessage; } QString getLoginMessage() const { QMutexLocker locker(&loginMessageMutex); return loginMessage; }
bool getGameShouldPing() const { return true; } bool getGameShouldPing() const { return true; }
int getPingClockInterval() const { return pingClockInterval; }
int getMaxGameInactivityTime() const { return maxGameInactivityTime; } int getMaxGameInactivityTime() const { return maxGameInactivityTime; }
int getMaxPlayerInactivityTime() const { return maxPlayerInactivityTime; } int getMaxPlayerInactivityTime() const { return maxPlayerInactivityTime; }
int getMaxUsersPerAddress() const { return maxUsersPerAddress; } int getMaxUsersPerAddress() const { return maxUsersPerAddress; }