18 #include <boost/thread/mutex.hpp>
20 #include "mongo/base/disallow_copying.h"
22 #include "mongo/platform/atomic_word.h"
58 typedef AtomicUInt32::WordType ValType;
59 enum Mode { off, alwaysOn, random, nTimes, numModes };
60 enum RetCode { fastOff = 0, slowOff, slowOn };
72 if (MONGO_likely(ret == fastOff)) {
88 if (MONGO_likely((_fpInfo.loadRelaxed() & ACTIVE_BIT) == 0)) {
92 return slowShouldFailOpenBlock();
126 static const ValType ACTIVE_BIT = 1 << 31;
127 static const ValType REF_COUNTER_MASK = ~ACTIVE_BIT;
132 AtomicUInt32 _fpInfo;
136 AtomicInt32 _timesOrPeriod;
140 mutable boost::mutex _modMutex;
145 void enableFailPoint();
150 void disableFailPoint();
155 RetCode slowShouldFailOpenBlock();
161 const BSONObj& getData()
const;
189 _shouldClose = ret != FailPoint::fastOff;
190 return ret == FailPoint::slowOn;
205 #define MONGO_FAIL_POINT(symbol) MONGO_unlikely(symbol.shouldFail())
211 #define MONGO_FAIL_POINT_BLOCK(symbol, blockSymbol) \
212 for (mongo::ScopedFailPoint blockSymbol(&symbol); MONGO_unlikely(blockSymbol.isActive());)
bool shouldFail()
Note: This is not side-effect free - it can change the state to OFF after calling.
Definition: fail_point.h:69
Helper class for making sure that FailPoint::shouldFailCloseBlock is called when FailPoint::shouldFai...
Definition: fail_point.h:171
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
bool isActive()
Definition: fail_point.h:181
RetCode shouldFailOpenBlock()
Checks whether fail point is active and increments the reference counter without decrementing it...
Definition: fail_point.h:87
A simple thread-safe fail point implementation that can be activated and deactivated, as well as embed temporary data into it.
Definition: fail_point.h:54
void shouldFailCloseBlock()
Decrements the reference counter.
void setMode(Mode mode, ValType val=0, const BSONObj &extra=BSONObj())
Changes the settings of this fail point.
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary represent...
Definition: bsonobj.h:78
const BSONObj & getData() const