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 bool getGameShouldPing() const { return false; }
virtual int getPingClockInterval() const { return 0; }
virtual int getMaxGameInactivityTime() const { return 9999999; }
virtual int getMaxPlayerInactivityTime() const { return 9999999; }
virtual int getMessageCountingInterval() const { return 0; }

View file

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

View file

@ -39,8 +39,8 @@ logfile=server.log
logfilters=""
; 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
clientkeepalive=5
; to verify the client has not timed out. Defaults is 1 seconds
clientkeepalive=1
; Maximum time in seconds a player can stay inactive with there client not even responding to pings, before is
; considered disconnected; default is 15

View file

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

View file

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