aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Shabalin <alex.shabalin@tweag.io>2021-11-24 14:50:08 +0100
committerAlex Shabalin <alex.shabalin@tweag.io>2021-11-24 14:50:08 +0100
commit2970ca18bf36c02860396f83f6c9d1c06414eea5 (patch)
treee54de57ead86788b465a358444d8b9f5379175d6
parent884674a8e20789250929a4cc6be3ad5445836e63 (diff)
Fix a minor data race with _isInterrupted
-rw-r--r--src/libutil/util.cc2
-rw-r--r--src/libutil/util.hh2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 5468d1ed1..defb77a10 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -1205,7 +1205,7 @@ void closeOnExec(int fd)
//////////////////////////////////////////////////////////////////////
-bool _isInterrupted = false;
+std::atomic<bool> _isInterrupted = false;
static thread_local bool interruptThrown = false;
thread_local std::function<bool()> interruptCheck;
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 708e01cf8..0bdb37a79 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -337,7 +337,7 @@ void closeOnExec(int fd);
/* User interruption. */
-extern bool _isInterrupted;
+extern std::atomic<bool> _isInterrupted;
extern thread_local std::function<bool()> interruptCheck;