summaryrefslogtreecommitdiff
path: root/src/mongo/util/fail_point.cpp
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2012-10-09 10:20:08 -0400
committerRandolph Tan <randolph@10gen.com>2012-10-09 13:01:05 -0400
commit3642e685769b2de9d153816b6054c27f6fe044e2 (patch)
tree4784f13b8acb9dc58e698461ab0e39fa097937f5 /src/mongo/util/fail_point.cpp
parent7418173c31f490ead15b556f95ee539299d87051 (diff)
downloadmongo-3642e685769b2de9d153816b6054c27f6fe044e2.tar.gz
SERVER-7300 Race Condition in FailPoint::setMode
Diffstat (limited to 'src/mongo/util/fail_point.cpp')
-rw-r--r--src/mongo/util/fail_point.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/mongo/util/fail_point.cpp b/src/mongo/util/fail_point.cpp
index 881d8c78329..eca5fd83170 100644
--- a/src/mongo/util/fail_point.cpp
+++ b/src/mongo/util/fail_point.cpp
@@ -62,7 +62,7 @@ namespace mongo {
_data = extra.copy();
if (_mode != off) {
- _fpInfo.store(ACTIVE_BIT);
+ enableFailPoint();
}
}
@@ -70,6 +70,19 @@ namespace mongo {
return _data;
}
+ void FailPoint::enableFailPoint() {
+ // TODO: Better to replace with a bitwise OR, once available for AU32
+ ValType currentVal = _fpInfo.load();
+ ValType expectedCurrentVal;
+ ValType newVal;
+
+ do {
+ expectedCurrentVal = currentVal;
+ newVal = expectedCurrentVal | ACTIVE_BIT;
+ currentVal = _fpInfo.compareAndSwap(expectedCurrentVal, newVal);
+ } while (expectedCurrentVal != currentVal);
+ }
+
void FailPoint::disableFailPoint() {
// TODO: Better to replace with a bitwise AND, once available for AU32
ValType currentVal = _fpInfo.load();