Forums WoW Modding Support Archives TrinityCore Discord Archives [DiscordArchive] Is this thread unsafe? There is a call like this _worldSession->ResetTimeOutTime(false) in the metho

[DiscordArchive] Is this thread unsafe? There is a call like this _worldSession->ResetTimeOutTime(false) in the metho

[DiscordArchive] Is this thread unsafe? There is a call like this _worldSession->ResetTimeOutTime(false) in the metho

rektbyfaith
Administrator
0
11-19-2024, 09:37 PM
#1
Archived author: Cristian • Posted: 2024-11-19T21:37:43.002000+00:00
Original source

Is this thread unsafe? There is a call like this _worldSession->ResetTimeOutTime(false) in the method WorldSocket::ReadDataHandler() that it is being called from the network thread. In the method WorldSession::ResetTimeOutTime(bool) there is a call to GameTime::GetGameTime() and that is the thing. That time is being updated at the beginning of World::Update(uint32) and that updated is being done by the main thread of the worldserver. I have inspected the GameTime.cpp file and I don’t any thread safe mechanism, no mutex, no atomics, the game time is just of type time_t (a simple long long).
So I have the question: Is this thread unsafe or I’m missing something?
rektbyfaith
11-19-2024, 09:37 PM #1

Archived author: Cristian • Posted: 2024-11-19T21:37:43.002000+00:00
Original source

Is this thread unsafe? There is a call like this _worldSession->ResetTimeOutTime(false) in the method WorldSocket::ReadDataHandler() that it is being called from the network thread. In the method WorldSession::ResetTimeOutTime(bool) there is a call to GameTime::GetGameTime() and that is the thing. That time is being updated at the beginning of World::Update(uint32) and that updated is being done by the main thread of the worldserver. I have inspected the GameTime.cpp file and I don’t any thread safe mechanism, no mutex, no atomics, the game time is just of type time_t (a simple long long).
So I have the question: Is this thread unsafe or I’m missing something?

rektbyfaith
Administrator
0
11-19-2024, 09:46 PM
#2
Archived author: Tea • Posted: 2024-11-19T21:46:00.539000+00:00
Original source

technically not safe (in a generic sense)
rektbyfaith
11-19-2024, 09:46 PM #2

Archived author: Tea • Posted: 2024-11-19T21:46:00.539000+00:00
Original source

technically not safe (in a generic sense)

rektbyfaith
Administrator
0
11-19-2024, 09:46 PM
#3
Archived author: Tea • Posted: 2024-11-19T21:46:02.731000+00:00
Original source

however
rektbyfaith
11-19-2024, 09:46 PM #3

Archived author: Tea • Posted: 2024-11-19T21:46:02.731000+00:00
Original source

however

rektbyfaith
Administrator
0
11-19-2024, 09:47 PM
#4
Archived author: Tea • Posted: 2024-11-19T21:47:19.998000+00:00
Original source

in practice this is safe on all cpu architectures supported by TC - 64 bit memory writes are atomic on both x86 and arm64
rektbyfaith
11-19-2024, 09:47 PM #4

Archived author: Tea • Posted: 2024-11-19T21:47:19.998000+00:00
Original source

in practice this is safe on all cpu architectures supported by TC - 64 bit memory writes are atomic on both x86 and arm64

rektbyfaith
Administrator
0
11-19-2024, 09:48 PM
#5
Archived author: Cristian • Posted: 2024-11-19T21:48:45.171000+00:00
Original source

Ok, interesting . So, i was missing something. Thanks for the answer.
rektbyfaith
11-19-2024, 09:48 PM #5

Archived author: Cristian • Posted: 2024-11-19T21:48:45.171000+00:00
Original source

Ok, interesting . So, i was missing something. Thanks for the answer.

Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)