From 9de175fb3776415e7237e6c0af4b76f518adc451 Mon Sep 17 00:00:00 2001 From: Henrik Edin Date: Fri, 31 Jul 2020 15:26:11 -0400 Subject: SERVER-47885 Added lookupCollectionByXXXForRead interface to the Collection catalog that returns collection as shared_ptr AutoGetCollectionForRead and AutoGetCollectionForReadCommand now uses this and holds the shared_ptr. They return the collection as const. Const correct various places to make this possible. Moved some logic from Collection destructors to deregister from the catalog as they may now be destroyed at a later point. --- src/mongo/db/dbhelpers.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/mongo/db/dbhelpers.h') diff --git a/src/mongo/db/dbhelpers.h b/src/mongo/db/dbhelpers.h index 7b606768d02..514a4eda352 100644 --- a/src/mongo/db/dbhelpers.h +++ b/src/mongo/db/dbhelpers.h @@ -59,18 +59,18 @@ struct Helpers { @return true if object found */ static bool findOne(OperationContext* opCtx, - Collection* collection, + const Collection* collection, const BSONObj& query, BSONObj& result, bool requireIndex = false); static RecordId findOne(OperationContext* opCtx, - Collection* collection, + const Collection* collection, const BSONObj& query, bool requireIndex); static RecordId findOne(OperationContext* opCtx, - Collection* collection, + const Collection* collection, std::unique_ptr qr, bool requireIndex); @@ -89,7 +89,9 @@ struct Helpers { /* TODO: should this move into Collection? * uasserts if no _id index. * @return null loc if not found */ - static RecordId findById(OperationContext* opCtx, Collection* collection, const BSONObj& query); + static RecordId findById(OperationContext* opCtx, + const Collection* collection, + const BSONObj& query); /** * Get the first object generated from a forward natural-order scan on "ns". Callers do not -- cgit v1.2.1