From 7768765fe8928976ab352e71ebf5a53db2bdc95e Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Tue, 14 Dec 2021 11:49:39 +0000 Subject: [PATCH] Fixed locking around notification Deduplication locking had test_and_set incorrect direction. --- src/pal/pal_ds.h | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/pal/pal_ds.h b/src/pal/pal_ds.h index 852d83c..543fb8a 100644 --- a/src/pal/pal_ds.h +++ b/src/pal/pal_ds.h @@ -146,18 +146,17 @@ namespace snmalloc // Depulicate calls into here, and make single threaded. if (lock.test_and_set()) - { - timers.apply_all([time_ms](PalTimerObject* curr) { - if ( - (curr->last_run == 0) || - ((time_ms - curr->last_run) > curr->repeat)) - { - curr->last_run = time_ms; - curr->pal_notify(curr); - } - }); - lock.clear(); - } + return; + + timers.apply_all([time_ms](PalTimerObject* curr) { + if ( + (curr->last_run == 0) || ((time_ms - curr->last_run) > curr->repeat)) + { + curr->last_run = time_ms; + curr->pal_notify(curr); + } + }); + lock.clear(); } }; } // namespace snmalloc