diff options
author | Justin Seyster <justin.seyster@mongodb.com> | 2017-08-01 17:02:22 -0400 |
---|---|---|
committer | Justin Seyster <justin.seyster@mongodb.com> | 2017-08-08 16:17:54 -0400 |
commit | 1583062723785c550874943007e6cdc1b7903e99 (patch) | |
tree | fee2959eacabe4e1ca6cc827e2fa4a9bff995239 /src | |
parent | 6446a633c2b89f0e84475d2e9857d5d3d6296086 (diff) | |
download | mongo-1583062723785c550874943007e6cdc1b7903e99.tar.gz |
SERVER-30124 Move statics from populateDocumentWithQueryFields.
We're seeing a test failure that could be explained by non-thread safe
initialization of function-level static variables in the version of
the C++11 spec used by the VS2013 compiler.
https://blogs.msdn.microsoft.com/oldnewthing/20040308-00/?p=40363
Moving those variables into file scope should ensure that
they get initialized safely.
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/ops/update_driver.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mongo/db/ops/update_driver.cpp b/src/mongo/db/ops/update_driver.cpp index c0c11082a2e..a99376174a8 100644 --- a/src/mongo/db/ops/update_driver.cpp +++ b/src/mongo/db/ops/update_driver.cpp @@ -183,6 +183,13 @@ Status UpdateDriver::populateDocumentWithQueryFields(const BSONObj& query, return populateDocumentWithQueryFields(*cq, immutablePaths, doc); } +namespace { + +const FieldRef idPath("_id"); +const vector<FieldRef*> emptyImmutablePaths; + +} // namespace + Status UpdateDriver::populateDocumentWithQueryFields(const CanonicalQuery& query, const vector<FieldRef*>* immutablePathsPtr, mutablebson::Document& doc) const { @@ -192,13 +199,12 @@ Status UpdateDriver::populateDocumentWithQueryFields(const CanonicalQuery& query if (isDocReplacement()) { FieldRefSet pathsToExtract; - // TODO: Refactor update logic, make _id just another immutable field - static const FieldRef idPath("_id"); - static const vector<FieldRef*> emptyImmutablePaths; const vector<FieldRef*>& immutablePaths = immutablePathsPtr ? *immutablePathsPtr : emptyImmutablePaths; pathsToExtract.fillFrom(immutablePaths); + + // TODO: Refactor update logic, make _id just another immutable field pathsToExtract.insert(&idPath); // Extract only immutable fields from replacement-style |