Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change server.daylight_active to an atomic variable (valkey-io#876)
We are updating this variable in the main thread, and the child threads can printing the logs at the same time. This generating a warning in SANITIZER=thread: ``` WARNING: ThreadSanitizer: data race (pid=74208) Read of size 4 at 0x000102875c10 by thread T3: #0 serverLogRaw <null>:52173615 (valkey-server:x86_64+0x10003c556) valkey-io#1 _serverLog <null>:52173615 (valkey-server:x86_64+0x10003ca89) valkey-io#2 bioProcessBackgroundJobs <null>:52173615 (valkey-server:x86_64+0x1001402c9) Previous write of size 4 at 0x000102875c10 by main thread (mutexes: write M0): #0 afterSleep <null>:52173615 (valkey-server:x86_64+0x10004989b) valkey-io#1 aeProcessEvents <null>:52173615 (valkey-server:x86_64+0x100031e52) valkey-io#2 main <null>:52173615 (valkey-server:x86_64+0x100064a3c) valkey-io#3 start <null>:52173615 (dyld:x86_64+0xfffffffffff5c365) valkey-io#4 start <null>:52173615 (dyld:x86_64+0xfffffffffff5c365) ``` The refresh of daylight_active is not real time, we update it in aftersleep, so we don't need a strong synchronization, so using memory_order_relaxed. But also noted we are doing load/store operations only for daylight_active, which is an aligned 32-bit integer, so using memory_order_relaxed will not provide more consistency than what we have today. So this is just a cleanup that to clear the warning. Signed-off-by: Binbin <[email protected]> Signed-off-by: mwish <[email protected]>
- Loading branch information