aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2017-11-30 20:35:57 +0100
committerfunjoker <funjoker109@gmail.com>2021-02-25 18:50:55 +0100
commitf1388f37b6151252aae7431921564cf2458226a4 (patch)
treeee029c4fc2454ab2e5ff9c82168f9fa155676894 /src
parentd04a927316bdd2a0aec8498a3523b3e43b64a275 (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). (cherry picked from commit 032194099e84bf0d47b121d82170c39fe73e0c87)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Server/WorldSession.cpp12
-rw-r--r--src/server/game/Server/WorldSession.h12
-rw-r--r--src/server/game/World/World.cpp6
3 files changed, 13 insertions, 17 deletions
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index 6ac4bca9ca3..2a4771f4015 100644
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -323,9 +323,6 @@ void WorldSession::LogUnprocessedTail(WorldPacket const* 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)
@@ -702,9 +699,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(WorldPackets::Null& null)
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 423d83d582e..c8fcd89ac75 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -1096,19 +1096,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 5a58d2c3a4d..4dada5a5091 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -810,8 +810,10 @@ void World::LoadConfigSettings(bool reload)
m_int_configs[CONFIG_PORT_INSTANCE] = sConfigMgr->GetIntDefault("InstanceServerPort", 8086);
}
- 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);