Example #1
0
void FailPoint::setMode(Mode mode, ValType val, const BSONObj& extra) {
    /**
     * Outline:
     *
     * 1. Deactivates fail point to enter write-only mode
     * 2. Waits for all current readers of the fail point to finish
     * 3. Sets the new mode.
     */

    stdx::lock_guard<stdx::mutex> scoped(_modMutex);

    // Step 1
    disableFailPoint();

    // Step 2
    while (_fpInfo.load() != 0) {
        sleepmillis(50);
    }

    _mode = mode;
    _timesOrPeriod.store(val);

    _data = extra.copy();

    if (_mode != off) {
        enableFailPoint();
    }
}
Example #2
0
    void FailPoint::setMode(Mode mode, ValType val, const BSONObj& extra) {
        /**
         * Outline:
         *
         * 1. Deactivates fail point to enter write-only mode
         * 2. Waits for all current readers of the fail point to finish
         * 3. Sets the new mode.
         */

        scoped_lock scoped(_modMutex);

        // Step 1
        disableFailPoint();

        // Step 2
        while (_fpInfo.load() != 0) {
            sleepmillis(50);
        }

        // Step 3
        uassert(16442, stream() << "mode not supported " << static_cast<int>(mode),
                mode >= off && mode < numModes);

        _mode = mode;
        _timesOrPeriod.store(val);

        _data = extra.copy();

        if (_mode != off) {
            enableFailPoint();
        }
    }