aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/jobqueue.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-12-19 10:54:11 +0100
committerGitHub <[email protected]>2023-12-19 10:54:11 +0100
commita8c4854f60d72d083bd34b34a9ccccc7353d052c (patch)
treeb67f14491390e81142f8293a20bc200be58c3fbb /src/zencore/jobqueue.cpp
parentfix ChunkIndexToChunkHash indexing (#621) (diff)
downloadzen-a8c4854f60d72d083bd34b34a9ccccc7353d052c.tar.xz
zen-a8c4854f60d72d083bd34b34a9ccccc7353d052c.zip
various TSAN/ASAN/LeakAnalyzer fixes (#622)
* fix JobQueue test threading issue. The inner job queued with `QueueJob` would reference `I` from inside the captured closure which would subsequently disappear * made sure application exit is thread safe * don't try to access string data out of bounds * keep-alive flag is accessed from multiple threads * fix memory leaks in Zen upstream client code * TSAN fixes for Event
Diffstat (limited to 'src/zencore/jobqueue.cpp')
-rw-r--r--src/zencore/jobqueue.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/zencore/jobqueue.cpp b/src/zencore/jobqueue.cpp
index 1755b9fe9..4bcc5c885 100644
--- a/src/zencore/jobqueue.cpp
+++ b/src/zencore/jobqueue.cpp
@@ -422,8 +422,10 @@ TEST_CASE("JobQueue")
{
JobsLatch.AddCount(1);
Pool.ScheduleWork([&Queue, &JobsLatch, I]() {
- auto _ = MakeGuard([&JobsLatch]() { JobsLatch.CountDown(); });
- auto Id = Queue->QueueJob(fmt::format("busy {}", I), [&](JobContext& Context) {
+ auto _ = MakeGuard([&JobsLatch]() { JobsLatch.CountDown(); });
+ JobsLatch.AddCount(1);
+ auto Id = Queue->QueueJob(fmt::format("busy {}", I), [&JobsLatch, I](JobContext& Context) {
+ auto $ = MakeGuard([&JobsLatch]() { JobsLatch.CountDown(); });
if (Context.IsCancelled())
{
return;
@@ -523,7 +525,6 @@ TEST_CASE("JobQueue")
}
JobsLatch.Wait();
}
-
#endif
} // namespace zen