aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2017-11-30 20:35:57 +0100
committerjackpoz <giacomopoz@gmail.com>2017-11-30 20:35:57 +0100
commit032194099e84bf0d47b121d82170c39fe73e0c87 (patch)
tree604007e5ee74c74a1055e9f8f9fdb59f294bdfbf /src
parent69078a1b1c49c199f592d71460533b4194d89966 (diff)
Core/WorldSession: Fix idle WorldSessions getting kicked twice as fast as supposed
Fix SocketTimeOutTime and SocketTimeOutTimeActive settings being effectively halved by reducing the timeout time twice every update instead of just once, causing much faster kicks (i.e. after 30 seconds with 60 seconds set in the configs).
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Server/WorldSession.cpp13
-rw-r--r--src/server/game/Server/WorldSession.h12
-rw-r--r--src/server/game/World/World.cpp6
3 files changed, 14 insertions, 17 deletions
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index a5a4f9139b2..58f9bbda64d 100644
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -28,6 +28,7 @@
#include "Common.h"
#include "DatabaseEnv.h"
#include "DBCStructure.h"
+#include "GameTime.h"
#include "Group.h"
#include "Guild.h"
#include "GuildMgr.h"
@@ -267,9 +268,6 @@ void WorldSession::LogUnprocessedTail(WorldPacket* packet)
/// Update the WorldSession (triggered by World update)
bool WorldSession::Update(uint32 diff, PacketFilter& updater)
{
- /// Update Timeout timer.
- UpdateTimeOutTime(diff);
-
///- Before we process anything:
/// If necessary, kick the player because the client didn't send anything for too long
/// (or they've been idling in character select)
@@ -637,9 +635,14 @@ char const* WorldSession::GetTrinityString(uint32 entry) const
void WorldSession::ResetTimeOutTime(bool onlyActive)
{
if (GetPlayer())
- m_timeOutTime = int32(sWorld->getIntConfig(CONFIG_SOCKET_TIMEOUTTIME_ACTIVE));
+ m_timeOutTime = GameTime::GetGameTime() + time_t(sWorld->getIntConfig(CONFIG_SOCKET_TIMEOUTTIME_ACTIVE));
else if (!onlyActive)
- m_timeOutTime = int32(sWorld->getIntConfig(CONFIG_SOCKET_TIMEOUTTIME));
+ m_timeOutTime = GameTime::GetGameTime() + time_t(sWorld->getIntConfig(CONFIG_SOCKET_TIMEOUTTIME));
+}
+
+bool WorldSession::IsConnectionIdle() const
+{
+ return m_timeOutTime < GameTime::GetGameTime() && !m_inQueue;
}
void WorldSession::Handle_NULL(WorldPacket& null)
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 237fa991456..2caba989384 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -432,19 +432,11 @@ class TC_GAME_API WorldSession
void SetLatency(uint32 latency) { m_latency = latency; }
void ResetClientTimeDelay() { m_clientTimeDelay = 0; }
- std::atomic<int32> m_timeOutTime;
-
- void UpdateTimeOutTime(uint32 diff)
- {
- m_timeOutTime -= int32(diff);
- }
+ std::atomic<time_t> m_timeOutTime;
void ResetTimeOutTime(bool onlyActive);
- bool IsConnectionIdle() const
- {
- return m_timeOutTime <= 0 && !m_inQueue;
- }
+ bool IsConnectionIdle() const;
// Recruit-A-Friend Handling
uint32 GetRecruiterId() const { return recruiterId; }
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 03081a113de..9e4a1ca3a45 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -721,8 +721,10 @@ void World::LoadConfigSettings(bool reload)
else
m_int_configs[CONFIG_PORT_WORLD] = sConfigMgr->GetIntDefault("WorldServerPort", 8085);
- m_int_configs[CONFIG_SOCKET_TIMEOUTTIME] = sConfigMgr->GetIntDefault("SocketTimeOutTime", 900000);
- m_int_configs[CONFIG_SOCKET_TIMEOUTTIME_ACTIVE] = sConfigMgr->GetIntDefault("SocketTimeOutTimeActive", 60000);
+ // Config values are in "milliseconds" but we handle SocketTimeOut only as "seconds" so divide by 1000
+ m_int_configs[CONFIG_SOCKET_TIMEOUTTIME] = sConfigMgr->GetIntDefault("SocketTimeOutTime", 900000) / 1000;
+ m_int_configs[CONFIG_SOCKET_TIMEOUTTIME_ACTIVE] = sConfigMgr->GetIntDefault("SocketTimeOutTimeActive", 60000) / 1000;
+
m_int_configs[CONFIG_SESSION_ADD_DELAY] = sConfigMgr->GetIntDefault("SessionAddDelay", 10000);
m_float_configs[CONFIG_GROUP_XP_DISTANCE] = sConfigMgr->GetFloatDefault("MaxGroupXPDistance", 74.0f);