From 5402edd41bdfe46c94ef6c3a0dda2bb7e4fce1f3 Mon Sep 17 00:00:00 2001 From: kamel5 Date: Wed, 15 Jul 2020 11:36:26 +0200 Subject: [PATCH] Update Locking in extensions/globaltimers.c --- extensions/globaltimers.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/extensions/globaltimers.c b/extensions/globaltimers.c index 1d8092f..8de97ce 100644 --- a/extensions/globaltimers.c +++ b/extensions/globaltimers.c @@ -52,11 +52,14 @@ void cGlobalTimers::MarkLocalTimers(void) { delete[] localTimer; localTimer = NULL; } + const cTimers* timers; #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + { LOCK_TIMERS_READ; - const cTimers* timers = Timers; + timers = Timers; + } #else - const cTimers* timers = &Timers; + timers = &Timers; #endif int numTimers = Size(); if (numTimers > 0) { @@ -78,14 +81,17 @@ void cGlobalTimers::MarkLocalTimers(void) { } void cGlobalTimers::SetLocalTimers(void) { + const cTimers* timers; #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + { LOCK_TIMERS_READ; - const cTimers* timers = Timers; + timers = Timers; + } #else - const cTimers* timers = &Timers; + timers = &Timers; #endif for (const cTimer *Timer = timers->First(); Timer; Timer = timers->Next(Timer)) { - if (Timer->HasFlags(tfActive)) + if (Timer && Timer->HasFlags(tfActive)) Append(Timer); } }