summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2020-10-06 16:30:19 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-13 01:10:51 +0000
commit0f0db59f8fc1166f05c45049e9ae230cf9c6e9f0 (patch)
treeeee5796e5cd6b2731f5c542d5326623a4d6dd7a7
parentbcab0c7e1c1b2e1516d06d23233fea9a425b99f7 (diff)
downloadmongo-0f0db59f8fc1166f05c45049e9ae230cf9c6e9f0.tar.gz
SERVER-51180 Fix uninitialized variables in CollectionCatalog::iterator when using constructor for end iterator.
They were basically harmless but would cause problem if iterators are compared other way around. This will make the comparison operator symmetric.
-rw-r--r--src/mongo/db/catalog/collection_catalog.cpp8
-rw-r--r--src/mongo/db/catalog/collection_catalog.h4
2 files changed, 8 insertions, 4 deletions
diff --git a/src/mongo/db/catalog/collection_catalog.cpp b/src/mongo/db/catalog/collection_catalog.cpp
index cbfca442750..4db4b069794 100644
--- a/src/mongo/db/catalog/collection_catalog.cpp
+++ b/src/mongo/db/catalog/collection_catalog.cpp
@@ -209,8 +209,10 @@ CollectionCatalog::iterator::iterator(OperationContext* opCtx,
CollectionCatalog::iterator::iterator(OperationContext* opCtx,
std::map<std::pair<std::string, CollectionUUID>,
- std::shared_ptr<Collection>>::const_iterator mapIter)
- : _opCtx(opCtx), _mapIter(mapIter) {}
+ std::shared_ptr<Collection>>::const_iterator mapIter,
+ uint64_t genNum,
+ const CollectionCatalog& catalog)
+ : _opCtx(opCtx), _genNum(genNum), _mapIter(mapIter), _catalog(&catalog) {}
CollectionCatalog::iterator::value_type CollectionCatalog::iterator::operator*() {
stdx::lock_guard<Latch> lock(_catalog->_catalogLock);
@@ -846,7 +848,7 @@ CollectionCatalog::iterator CollectionCatalog::begin(OperationContext* opCtx, St
}
CollectionCatalog::iterator CollectionCatalog::end(OperationContext* opCtx) const {
- return iterator(opCtx, _orderedCollections.end());
+ return iterator(opCtx, _orderedCollections.end(), _generationNumber, *this);
}
boost::optional<std::string> CollectionCatalog::lookupResourceName(const ResourceId& rid) {
diff --git a/src/mongo/db/catalog/collection_catalog.h b/src/mongo/db/catalog/collection_catalog.h
index ec55e116c1a..836acd4c9ef 100644
--- a/src/mongo/db/catalog/collection_catalog.h
+++ b/src/mongo/db/catalog/collection_catalog.h
@@ -81,7 +81,9 @@ public:
const CollectionCatalog& catalog);
iterator(OperationContext* opCtx,
std::map<std::pair<std::string, CollectionUUID>,
- std::shared_ptr<Collection>>::const_iterator mapIter);
+ std::shared_ptr<Collection>>::const_iterator mapIter,
+ uint64_t genNum,
+ const CollectionCatalog& catalog);
value_type operator*();
iterator operator++();
iterator operator++(int);