diff options
author | Louis Williams <louis.williams@mongodb.com> | 2017-10-04 16:52:54 -0400 |
---|---|---|
committer | Louis Williams <louis.williams@mongodb.com> | 2017-10-06 17:46:07 -0400 |
commit | 3d42a318626e059b2669356bb5d39056b8fa1b76 (patch) | |
tree | 72765174ead0fc800bfc678b7a7ce9152ba586c0 /src/mongo/db/server_options.h | |
parent | bb71f4a4bea6c030675477d0dce18f77d0ee4b4b (diff) | |
download | mongo-3d42a318626e059b2669356bb5d39056b8fa1b76.tar.gz |
SERVER-30745 Prohibit unsafe comparisons against featureCompatibilityVersion
Diffstat (limited to 'src/mongo/db/server_options.h')
-rw-r--r-- | src/mongo/db/server_options.h | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/mongo/db/server_options.h b/src/mongo/db/server_options.h index 76b2df4aa6c..c3cd1b89b8d 100644 --- a/src/mongo/db/server_options.h +++ b/src/mongo/db/server_options.h @@ -167,25 +167,36 @@ struct ServerGlobalParams { */ enum class Version { k34, k36, kUnset }; - AtomicWord<Version> version{Version::k34}; + const Version getVersion() const { + return _version.load(); + } - // If set, an upgrade or downgrade is in progress to the set version. - AtomicWord<Version> targetVersion{Version::kUnset}; + void setVersion(Version version) { + return _version.store(version); + } + + const Version getTargetVersion() const { + return _targetVersion.load(); + } + + void setTargetVersion(Version version) { + return _targetVersion.store(version); + } const bool isFullyUpgradedTo36() { - return (version.load() == Version::k36 && targetVersion.load() == Version::kUnset); + return (_version.load() == Version::k36 && _targetVersion.load() == Version::kUnset); } const bool isUpgradingTo36() { - return (version.load() == Version::k34 && targetVersion.load() == Version::k36); + return (_version.load() == Version::k34 && _targetVersion.load() == Version::k36); } const bool isFullyDowngradedTo34() { - return (version.load() == Version::k34 && targetVersion.load() == Version::kUnset); + return (_version.load() == Version::k34 && _targetVersion.load() == Version::kUnset); } const bool isDowngradingTo34() { - return (version.load() == Version::k34 && targetVersion.load() == Version::k34); + return (_version.load() == Version::k34 && _targetVersion.load() == Version::k34); } // This determines whether to give Collections UUIDs upon creation. @@ -199,6 +210,13 @@ struct ServerGlobalParams { // a master) always validates in "3.4" mode so that it can sync 3.4 features, even when in // "3.2" feature compatibility mode. AtomicWord<bool> validateFeaturesAsMaster{true}; + + private: + AtomicWord<Version> _version{Version::k34}; + + // If set, an upgrade or downgrade is in progress to the set version. + AtomicWord<Version> _targetVersion{Version::kUnset}; + } featureCompatibility; std::vector<std::string> disabledSecureAllocatorDomains; |