summaryrefslogtreecommitdiff
path: root/src/mongo/db/db_raii.h
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2015-08-21 20:31:40 -0400
committerBenety Goh <benety@mongodb.com>2015-08-21 20:31:40 -0400
commit045cd1070cae1e7827255850c2fe35194e48b24e (patch)
tree154354109f0039ff21d6e93e0b1687115f184751 /src/mongo/db/db_raii.h
parent6124799c4e14d1ffc9419e6548ec96626e73dcda (diff)
downloadmongo-045cd1070cae1e7827255850c2fe35194e48b24e.tar.gz
Revert "SERVER-19855 Do not perform shard version checking where not necessary"
This reverts commit 31716d2ae526d82d7d36464f6c9fae8b9f38542f.
Diffstat (limited to 'src/mongo/db/db_raii.h')
-rw-r--r--src/mongo/db/db_raii.h42
1 files changed, 8 insertions, 34 deletions
diff --git a/src/mongo/db/db_raii.h b/src/mongo/db/db_raii.h
index b6522caad2b..b37112cb267 100644
--- a/src/mongo/db/db_raii.h
+++ b/src/mongo/db/db_raii.h
@@ -45,7 +45,7 @@ class Collection;
* RAII-style class, which acquires a lock on the specified database in the requested mode and
* obtains a reference to the database. Used as a shortcut for calls to dbHolder().get().
*
- * It is guaranteed that the lock will be released when this object goes out of scope, therefore
+ * It is guaranteed that locks will be released when this object goes out of scope, therefore
* the database reference returned by this class should not be retained.
*/
class AutoGetDb {
@@ -64,33 +64,6 @@ private:
};
/**
- * RAII-style class, which acquires a locks on the specified database and collection in the
- * requested mode and obtains references to both.
- *
- * It is guaranteed that locks will be released when this object goes out of scope, therefore
- * the database and the collection references returned by this class should not be retained.
- */
-class AutoGetCollection {
- MONGO_DISALLOW_COPYING(AutoGetCollection);
-
-public:
- AutoGetCollection(OperationContext* txn, const NamespaceString& nss, LockMode mode);
-
- Database* getDb() const {
- return _autoDb.getDb();
- }
-
- Collection* getCollection() const {
- return _coll;
- }
-
-private:
- const AutoGetDb _autoDb;
- const Lock::CollectionLock _collLock;
- Collection* const _coll;
-};
-
-/**
* RAII-style class, which acquires a lock on the specified database in the requested mode and
* obtains a reference to the database, creating it was non-existing. Used as a shortcut for
* calls to dbHolder().openDb(), taking care of locking details. The requested mode must be
@@ -127,9 +100,7 @@ private:
/**
* RAII-style class, which would acquire the appropritate hierarchy of locks for obtaining
- * a particular collection and would retrieve a reference to the collection. In addition, this
- * utility validates the shard version for the specified namespace and sets the current operation's
- * namespace for the duration while this object is alive.
+ * a particular collection and would retrieve a reference to the collection.
*
* It is guaranteed that locks will be released when this object goes out of scope, therefore
* database and collection references returned by this class should not be retained.
@@ -143,11 +114,11 @@ public:
~AutoGetCollectionForRead();
Database* getDb() const {
- return _autoColl.getDb();
+ return _db.getDb();
}
Collection* getCollection() const {
- return _autoColl.getCollection();
+ return _coll;
}
private:
@@ -156,7 +127,10 @@ private:
const Timer _timer;
OperationContext* const _txn;
const ScopedTransaction _transaction;
- const AutoGetCollection _autoColl;
+ const AutoGetDb _db;
+ const Lock::CollectionLock _collLock;
+
+ Collection* _coll;
};
/**