diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2021-09-20 23:27:51 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-09-21 00:07:27 +0000 |
commit | 6ff19433eb6f8dba381c6736a364b1967ba43541 (patch) | |
tree | 1bd33b8672534daf118441c67280b1bfc217ff93 | |
parent | 5e28775ebde238a628532dc5dd947b55b815310b (diff) | |
download | mongo-6ff19433eb6f8dba381c6736a364b1967ba43541.tar.gz |
SERVER-60022 global std::optional -> boost::optional
-rw-r--r-- | buildscripts/linter/simplecpplint.py | 8 | ||||
-rw-r--r-- | src/mongo/db/curop.h | 2 | ||||
-rw-r--r-- | src/mongo/db/exec/plan_stats.h | 2 | ||||
-rw-r--r-- | src/mongo/db/query/plan_summary_stats.h | 2 | ||||
-rw-r--r-- | src/mongo/db/query/sbe_stage_builder.h | 2 | ||||
-rw-r--r-- | src/mongo/transport/ssl_connection_context.h | 2 | ||||
-rw-r--r-- | src/mongo/util/net/ssl_manager.h | 6 | ||||
-rw-r--r-- | src/mongo/util/net/ssl_manager_apple.cpp | 2 | ||||
-rw-r--r-- | src/mongo/util/net/ssl_manager_openssl.cpp | 43 | ||||
-rw-r--r-- | src/mongo/util/net/ssl_manager_windows.cpp | 2 |
10 files changed, 40 insertions, 31 deletions
diff --git a/buildscripts/linter/simplecpplint.py b/buildscripts/linter/simplecpplint.py index 11f7056d8bc..7f20d7b11d6 100644 --- a/buildscripts/linter/simplecpplint.py +++ b/buildscripts/linter/simplecpplint.py @@ -58,6 +58,7 @@ _RE_VOLATILE = re.compile('[^_]volatile') _RE_MUTEX = re.compile('[ ({,]stdx?::mutex[ ({]') _RE_ASSERT = re.compile(r'\bassert\s*\(') _RE_UNSTRUCTURED_LOG = re.compile(r'\blogd\s*\(') +_RE_STD_OPTIONAL = re.compile(r'\bstd::optional\b') _RE_GENERIC_FCV_COMMENT = re.compile(r'\(Generic FCV reference\):') GENERIC_FCV = [ @@ -143,6 +144,7 @@ class Linter: self._check_for_mongo_unstructured_log(linenum) self._check_for_mongo_config_header(linenum) self._check_for_ctype(linenum) + self._check_for_std_optional(linenum) # Relax the rule of commenting generic FCV references for files directly related to FCV # implementations. @@ -246,6 +248,12 @@ class Linter: self._error(linenum, 'mongodb/ctype', 'Use of prohibited <ctype.h> or <cctype> header, use "mongo/util/ctype.h"') + def _check_for_std_optional(self, linenum): + line = self.clean_lines[linenum] + if _RE_STD_OPTIONAL.search(line): + self._error(linenum, 'mongodb/stdoptional', + 'Use of std::optional, use boost::optional instead.') + def _license_error(self, linenum, msg, category='legal/license'): style_url = 'https://github.com/mongodb/mongo/wiki/Server-Code-Style' self._error(linenum, category, '{} See {}'.format(msg, style_url)) diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h index 621106e3e0d..4dee28cb495 100644 --- a/src/mongo/db/curop.h +++ b/src/mongo/db/curop.h @@ -242,7 +242,7 @@ public: bool fromMultiPlanner{false}; // True if a replan was triggered during the execution of this operation. - std::optional<std::string> replanReason; + boost::optional<std::string> replanReason; bool cursorExhausted{ false}; // true if the cursor has been closed at end a find/getMore operation diff --git a/src/mongo/db/exec/plan_stats.h b/src/mongo/db/exec/plan_stats.h index d38bf6c9437..fd662242b72 100644 --- a/src/mongo/db/exec/plan_stats.h +++ b/src/mongo/db/exec/plan_stats.h @@ -223,7 +223,7 @@ struct CachedPlanStats : public SpecificStats { return sizeof(*this); } - std::optional<std::string> replanReason; + boost::optional<std::string> replanReason; }; struct CollectionScanStats : public SpecificStats { diff --git a/src/mongo/db/query/plan_summary_stats.h b/src/mongo/db/query/plan_summary_stats.h index 129c4f83895..be0c47d922c 100644 --- a/src/mongo/db/query/plan_summary_stats.h +++ b/src/mongo/db/query/plan_summary_stats.h @@ -111,7 +111,7 @@ struct PlanSummaryStats { bool fromMultiPlanner = false; // Was a replan triggered during the execution of this query? - std::optional<std::string> replanReason; + boost::optional<std::string> replanReason; // Score calculated for the plan by PlanRanker. Only set if there were multiple candidate plans // and allPlansExecution verbosity mode is selected. diff --git a/src/mongo/db/query/sbe_stage_builder.h b/src/mongo/db/query/sbe_stage_builder.h index 70dfcc6a629..95eaff653ac 100644 --- a/src/mongo/db/query/sbe_stage_builder.h +++ b/src/mongo/db/query/sbe_stage_builder.h @@ -261,7 +261,7 @@ struct PlanStageData { // If this execution tree was built as a result of replanning of the cached plan, this string // will include the reason for replanning. - std::optional<std::string> replanReason; + boost::optional<std::string> replanReason; // If this candidate plan has completed the trial run early by achieving one of the trial run // metrics, the stats are cached in here. diff --git a/src/mongo/transport/ssl_connection_context.h b/src/mongo/transport/ssl_connection_context.h index 0ab7c23091d..3859bb39c54 100644 --- a/src/mongo/transport/ssl_connection_context.h +++ b/src/mongo/transport/ssl_connection_context.h @@ -55,7 +55,7 @@ struct SSLConnectionContext { std::shared_ptr<SSLManagerInterface> manager; // If this Context was created from transient SSL params this contains the URI of the target // cluster. It can also be used to determine if the context is indeed transient. - std::optional<std::string> targetClusterURI; + boost::optional<std::string> targetClusterURI; ~SSLConnectionContext(); }; diff --git a/src/mongo/util/net/ssl_manager.h b/src/mongo/util/net/ssl_manager.h index 124fd6ae1e3..a20ca9946f6 100644 --- a/src/mongo/util/net/ssl_manager.h +++ b/src/mongo/util/net/ssl_manager.h @@ -174,10 +174,10 @@ struct CertInformationToLog { Date_t validityNotAfter; // If the certificate was loaded from file, this is the file name. If empty, // it means the certificate came from memory payload. - std::optional<std::string> keyFile; + boost::optional<std::string> keyFile; // If the certificate targets a particular cluster, this is cluster URI. If empty, // it means the certificate is the default one for the local cluster. - std::optional<std::string> targetClusterURI; + boost::optional<std::string> targetClusterURI; logv2::DynamicAttributes getDynamicAttributes() const { logv2::DynamicAttributes attrs; @@ -217,7 +217,7 @@ public: */ static std::shared_ptr<SSLManagerInterface> create( const SSLParams& params, - const std::optional<TransientSSLParams>& transientSSLParams, + const boost::optional<TransientSSLParams>& transientSSLParams, bool isServer); /** diff --git a/src/mongo/util/net/ssl_manager_apple.cpp b/src/mongo/util/net/ssl_manager_apple.cpp index aba7cbb39ce..ec77dc17722 100644 --- a/src/mongo/util/net/ssl_manager_apple.cpp +++ b/src/mongo/util/net/ssl_manager_apple.cpp @@ -1872,7 +1872,7 @@ extern SSLManagerCoordinator* theSSLManagerCoordinator; std::shared_ptr<SSLManagerInterface> SSLManagerInterface::create( const SSLParams& params, - const std::optional<TransientSSLParams>& transientSSLParams, + const boost::optional<TransientSSLParams>& transientSSLParams, bool isServer) { return std::make_shared<SSLManagerApple>(params, isServer); } diff --git a/src/mongo/util/net/ssl_manager_openssl.cpp b/src/mongo/util/net/ssl_manager_openssl.cpp index d50556b7ec3..3d92a683c1d 100644 --- a/src/mongo/util/net/ssl_manager_openssl.cpp +++ b/src/mongo/util/net/ssl_manager_openssl.cpp @@ -1162,7 +1162,7 @@ class SSLManagerOpenSSL : public SSLManagerInterface, public std::enable_shared_from_this<SSLManagerOpenSSL> { public: explicit SSLManagerOpenSSL(const SSLParams& params, - const std::optional<TransientSSLParams>& transientSSLParams, + const boost::optional<TransientSSLParams>& transientSSLParams, bool isServer); ~SSLManagerOpenSSL() { stopJobs(); @@ -1245,7 +1245,7 @@ private: SSLConfiguration _sslConfiguration; // If set, this manager is an instance providing authentication with remote server specified // with TransientSSLParams::targetedClusterConnectionString. - const std::optional<TransientSSLParams> _transientSSLParams; + const boost::optional<TransientSSLParams> _transientSSLParams; // Weak pointer to verify that this manager is still owned by this context. synchronized_value<std::weak_ptr<const SSLConnectionContext>> _ownedByContext; @@ -1384,8 +1384,8 @@ private: */ static void _getX509CertInfo(UniqueX509& x509, CertInformationToLog* info, - std::optional<StringData> keyFile, - std::optional<StringData> targetClusterURI); + boost::optional<StringData> keyFile, + boost::optional<StringData> targetClusterURI); /* * Retrieve and store CRL information from the provided CRL filename. @@ -1428,8 +1428,8 @@ private: bool _setupPEMFromBIO(SSL_CTX* context, UniqueBIO inBio, PasswordFetcher* password, - std::optional<StringData> keyFile, - std::optional<StringData> targetClusterURI) const; + boost::optional<StringData> keyFile, + boost::optional<StringData> targetClusterURI) const; /** * Loads a certificate chain from memory into context. @@ -1440,7 +1440,7 @@ private: static bool _readCertificateChainFromMemory(SSL_CTX* context, const std::string& payload, PasswordFetcher* password, - std::optional<StringData> targetClusterURI); + boost::optional<StringData> targetClusterURI); /* * Set up an SSL context for certificate validation by loading a CA @@ -1513,7 +1513,7 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(SSLManager, ("SetupOpenSSL", "EndStartupOpt std::shared_ptr<SSLManagerInterface> SSLManagerInterface::create( const SSLParams& params, - const std::optional<TransientSSLParams>& transientSSLParams, + const boost::optional<TransientSSLParams>& transientSSLParams, bool isServer) { return std::make_shared<SSLManagerOpenSSL>(params, transientSSLParams, isServer); } @@ -1521,7 +1521,7 @@ std::shared_ptr<SSLManagerInterface> SSLManagerInterface::create( std::shared_ptr<SSLManagerInterface> SSLManagerInterface::create(const SSLParams& params, bool isServer) { return std::make_shared<SSLManagerOpenSSL>( - params, std::optional<TransientSSLParams>{}, isServer); + params, boost::optional<TransientSSLParams>{}, isServer); } SSLX509Name getCertificateSubjectX509Name(X509* cert) { @@ -1613,7 +1613,7 @@ SSLConnectionOpenSSL::~SSLConnectionOpenSSL() { } SSLManagerOpenSSL::SSLManagerOpenSSL(const SSLParams& params, - const std::optional<TransientSSLParams>& transientSSLParams, + const boost::optional<TransientSSLParams>& transientSSLParams, bool isServer) : _serverContext(nullptr), _clientContext(nullptr), @@ -2662,7 +2662,7 @@ bool SSLManagerOpenSSL::_readCertificateChainFromMemory( SSL_CTX* context, const std::string& payload, PasswordFetcher* password, - std::optional<StringData> targetClusterURI) { + boost::optional<StringData> targetClusterURI) { logv2::DynamicAttributes errorAttrs; if (targetClusterURI) { @@ -2696,7 +2696,7 @@ bool SSLManagerOpenSSL::_readCertificateChainFromMemory( } CertInformationToLog debugInfo; - _getX509CertInfo(x509cert, &debugInfo, std::nullopt, targetClusterURI); + _getX509CertInfo(x509cert, &debugInfo, boost::none, targetClusterURI); logCert(debugInfo, "", 5159903); // SSL_CTX_use_certificate increments the refcount on cert. @@ -2724,7 +2724,7 @@ bool SSLManagerOpenSSL::_readCertificateChainFromMemory( 5159908, "Failed to use the CA X509 certificate loaded from memory", errorAttrs); return false; } - _getX509CertInfo(ca, &debugInfo, std::nullopt, targetClusterURI); + _getX509CertInfo(ca, &debugInfo, boost::none, targetClusterURI); logCert(debugInfo, "", 5159902); #if OPENSSL_VERSION_NUMBER < 0x100010fFL ca.release(); // Older version add_extra_chain_cert takes over the pointer without @@ -2770,7 +2770,7 @@ bool SSLManagerOpenSSL::_setupPEM(SSL_CTX* context, LOGV2_ERROR(23250, "Cannot read PEM key file", errorAttrs); return false; } - return _setupPEMFromBIO(context, std::move(inBio), password, keyFile, std::nullopt); + return _setupPEMFromBIO(context, std::move(inBio), password, StringData{keyFile}, boost::none); } bool SSLManagerOpenSSL::_setupPEMFromMemoryPayload(SSL_CTX* context, @@ -2795,14 +2795,14 @@ bool SSLManagerOpenSSL::_setupPEMFromMemoryPayload(SSL_CTX* context, return false; } - return _setupPEMFromBIO(context, std::move(inBio), password, std::nullopt, targetClusterURI); + return _setupPEMFromBIO(context, std::move(inBio), password, boost::none, targetClusterURI); } bool SSLManagerOpenSSL::_setupPEMFromBIO(SSL_CTX* context, UniqueBIO inBio, PasswordFetcher* password, - std::optional<StringData> keyFile, - std::optional<StringData> targetClusterURI) const { + boost::optional<StringData> keyFile, + boost::optional<StringData> targetClusterURI) const { logv2::DynamicAttributes errorAttrs; if (keyFile) { errorAttrs.add("keyFile", *keyFile); @@ -3499,8 +3499,8 @@ constexpr size_t kSHA1HashBytes = 20; // static void SSLManagerOpenSSL::_getX509CertInfo(UniqueX509& x509, CertInformationToLog* info, - std::optional<StringData> keyFile, - std::optional<StringData> targetClusterURI) { + boost::optional<StringData> keyFile, + boost::optional<StringData> targetClusterURI) { if (!x509) { return; } @@ -3579,7 +3579,8 @@ SSLInformationToLog SSLManagerOpenSSL::getSSLInformationToLog() const { if (!(sslGlobalParams.sslPEMKeyFile.empty())) { UniqueX509 serverX509Cert = _getX509Object(sslGlobalParams.sslPEMKeyFile, &_serverPEMPassword); - _getX509CertInfo(serverX509Cert, &info.server, sslGlobalParams.sslPEMKeyFile, std::nullopt); + _getX509CertInfo( + serverX509Cert, &info.server, StringData{sslGlobalParams.sslPEMKeyFile}, boost::none); } if (!(sslGlobalParams.sslClusterFile.empty())) { @@ -3587,7 +3588,7 @@ SSLInformationToLog SSLManagerOpenSSL::getSSLInformationToLog() const { UniqueX509 clusterX509Cert = _getX509Object(sslGlobalParams.sslClusterFile, &_clusterPEMPassword); _getX509CertInfo( - clusterX509Cert, &clusterInfo, sslGlobalParams.sslClusterFile, std::nullopt); + clusterX509Cert, &clusterInfo, StringData{sslGlobalParams.sslClusterFile}, boost::none); info.cluster = clusterInfo; } else { info.cluster = boost::none; diff --git a/src/mongo/util/net/ssl_manager_windows.cpp b/src/mongo/util/net/ssl_manager_windows.cpp index e7e212160cd..f5fe982a893 100644 --- a/src/mongo/util/net/ssl_manager_windows.cpp +++ b/src/mongo/util/net/ssl_manager_windows.cpp @@ -404,7 +404,7 @@ bool isSSLServer = false; std::shared_ptr<SSLManagerInterface> SSLManagerInterface::create( const SSLParams& params, - const std::optional<TransientSSLParams>& transientSSLParams, + const boost::optional<TransientSSLParams>& transientSSLParams, bool isServer) { return std::make_shared<SSLManagerWindows>(params, isServer); } |