aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/context.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-04-08 14:27:25 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-04-08 14:27:25 +0200
commit7376287554e30aa0b74136bf6c16566f6bda80cd (patch)
tree13b323d5a0b9eca9c5a3648aa099c48a80eb889c /libbuild2/context.cxx
parent70f7fd69b448263fc27b9dceba1663810f4885ab (diff)
Fix race in phase lock contention counting
Diffstat (limited to 'libbuild2/context.cxx')
-rw-r--r--libbuild2/context.cxx12
1 files changed, 6 insertions, 6 deletions
diff --git a/libbuild2/context.cxx b/libbuild2/context.cxx
index d460fa7..8052716 100644
--- a/libbuild2/context.cxx
+++ b/libbuild2/context.cxx
@@ -765,7 +765,7 @@ namespace build2
}
else if (ctx_.phase != n)
{
- ++contention;
+ ++contention; // Protected by m_.
ctx_.sched.deactivate (false /* external */);
for (; ctx_.phase != n; v->wait (l)) ;
@@ -783,11 +783,11 @@ namespace build2
{
if (!lm_.try_lock ())
{
- ++contention;
-
ctx_.sched.deactivate (false /* external */);
lm_.lock ();
ctx_.sched.activate (false /* external */);
+
+ ++contention_load; // Protected by lm_.
}
r = !fail_; // Re-query.
}
@@ -905,7 +905,7 @@ namespace build2
}
else // phase != n
{
- ++contention;
+ ++contention; // Protected by m_.
ctx_.sched.deactivate (false /* external */);
for (; ctx_.phase != n; v->wait (l)) ;
@@ -919,11 +919,11 @@ namespace build2
{
if (!lm_.try_lock ())
{
- ++contention;
-
ctx_.sched.deactivate (false /* external */);
lm_.lock ();
ctx_.sched.activate (false /* external */);
+
+ ++contention_load; // Protected by lm_.
}
r = !fail_; // Re-query.
}