summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r--src/mongo/db/catalog/collection_cursor_cache.cpp34
-rw-r--r--src/mongo/db/catalog/collection_cursor_cache.h8
-rw-r--r--src/mongo/db/catalog/database_holder.cpp5
-rw-r--r--src/mongo/db/catalog/database_holder.h5
4 files changed, 27 insertions, 25 deletions
diff --git a/src/mongo/db/catalog/collection_cursor_cache.cpp b/src/mongo/db/catalog/collection_cursor_cache.cpp
index 926baf7a137..d4727a17ee2 100644
--- a/src/mongo/db/catalog/collection_cursor_cache.cpp
+++ b/src/mongo/db/catalog/collection_cursor_cache.cpp
@@ -98,11 +98,11 @@ namespace mongo {
/**
* works globally
*/
- bool eraseCursor( CursorId id, bool checkAuth );
+ bool eraseCursor(OperationContext* txn, CursorId id, bool checkAuth);
void appendStats( BSONObjBuilder& builder );
- std::size_t timeoutCursors( int millisSinceLastCall );
+ std::size_t timeoutCursors(OperationContext* txn, int millisSinceLastCall);
int64_t nextSeed();
@@ -159,7 +159,7 @@ namespace mongo {
_idToNS.erase( id );
}
- bool GlobalCursorIdCache::eraseCursor(CursorId id, bool checkAuth) {
+ bool GlobalCursorIdCache::eraseCursor(OperationContext* txn, CursorId id, bool checkAuth) {
string ns;
{
SimpleMutex::scoped_lock lk( _mutex );
@@ -175,8 +175,8 @@ namespace mongo {
if ( checkAuth ) {
AuthorizationSession* as = cc().getAuthorizationSession();
- bool isAuthorized = as->isAuthorizedForActionsOnNamespace(nss,
- ActionType::killCursors);
+ bool isAuthorized = as->isAuthorizedForActionsOnNamespace(
+ txn, nss, ActionType::killCursors);
if ( !isAuthorized ) {
audit::logKillCursorsAuthzCheck( currentClient.get(),
nss,
@@ -186,8 +186,8 @@ namespace mongo {
}
}
- Lock::DBRead lock( ns );
- Database* db = dbHolder().get( ns, storageGlobalParams.dbpath );
+ Lock::DBRead lock(txn->lockState(), ns);
+ Database* db = dbHolder().get(ns, storageGlobalParams.dbpath);
if ( !db )
return false;
Client::Context context( ns, db );
@@ -204,7 +204,7 @@ namespace mongo {
return collection->cursorCache()->eraseCursor( id, checkAuth );
}
- std::size_t GlobalCursorIdCache::timeoutCursors( int millisSinceLastCall ) {
+ std::size_t GlobalCursorIdCache::timeoutCursors(OperationContext* txn, int millisSinceLastCall) {
vector<string> todo;
{
SimpleMutex::scoped_lock lk( _mutex );
@@ -216,7 +216,7 @@ namespace mongo {
for ( unsigned i = 0; i < todo.size(); i++ ) {
const string& ns = todo[i];
- Lock::DBRead lock( ns );
+ Lock::DBRead lock(txn->lockState(), ns);
Database* db = dbHolder().get( ns, storageGlobalParams.dbpath );
if ( !db )
continue;
@@ -235,25 +235,25 @@ namespace mongo {
// ---
- std::size_t CollectionCursorCache::timeoutCursorsGlobal( int millisSinceLastCall ) {
- return _globalCursorIdCache.timeoutCursors( millisSinceLastCall );
+ std::size_t CollectionCursorCache::timeoutCursorsGlobal(OperationContext* txn, int millisSinceLastCall) {;
+ return _globalCursorIdCache.timeoutCursors(txn, millisSinceLastCall);
}
- int CollectionCursorCache::eraseCursorGlobalIfAuthorized(int n, long long* ids) {
+ int CollectionCursorCache::eraseCursorGlobalIfAuthorized(OperationContext* txn, int n, long long* ids) {
int numDeleted = 0;
for ( int i = 0; i < n; i++ ) {
- if ( eraseCursorGlobalIfAuthorized( ids[i] ) )
+ if ( eraseCursorGlobalIfAuthorized(txn, ids[i] ) )
numDeleted++;
if ( inShutdown() )
break;
}
return numDeleted;
}
- bool CollectionCursorCache::eraseCursorGlobalIfAuthorized(CursorId id) {
- return _globalCursorIdCache.eraseCursor( id, true );
+ bool CollectionCursorCache::eraseCursorGlobalIfAuthorized(OperationContext* txn, CursorId id) {
+ return _globalCursorIdCache.eraseCursor(txn, id, true);
}
- bool CollectionCursorCache::eraseCursorGlobal( CursorId id ) {
- return _globalCursorIdCache.eraseCursor( id, false );
+ bool CollectionCursorCache::eraseCursorGlobal(OperationContext* txn, CursorId id) {
+ return _globalCursorIdCache.eraseCursor(txn, id, false );
}
diff --git a/src/mongo/db/catalog/collection_cursor_cache.h b/src/mongo/db/catalog/collection_cursor_cache.h
index bc057def73f..d08800d4d7b 100644
--- a/src/mongo/db/catalog/collection_cursor_cache.h
+++ b/src/mongo/db/catalog/collection_cursor_cache.h
@@ -109,15 +109,15 @@ namespace mongo {
// ----------------------
- static int eraseCursorGlobalIfAuthorized( int n, long long* ids );
- static bool eraseCursorGlobalIfAuthorized( CursorId id );
+ static int eraseCursorGlobalIfAuthorized(OperationContext* txn, int n, long long* ids);
+ static bool eraseCursorGlobalIfAuthorized(OperationContext* txn, CursorId id);
- static bool eraseCursorGlobal( CursorId id );
+ static bool eraseCursorGlobal(OperationContext* txn, CursorId id);
/**
* @return number timed out
*/
- static std::size_t timeoutCursorsGlobal( int millisSinceLastCall );
+ static std::size_t timeoutCursorsGlobal(OperationContext* txn, int millisSinceLastCall);
private:
CursorId _allocateCursorId_inlock();
diff --git a/src/mongo/db/catalog/database_holder.cpp b/src/mongo/db/catalog/database_holder.cpp
index 3516cc06a09..aeded6b196b 100644
--- a/src/mongo/db/catalog/database_holder.cpp
+++ b/src/mongo/db/catalog/database_holder.cpp
@@ -41,8 +41,7 @@
namespace mongo {
- Database* DatabaseHolder::getOrCreate( const string& ns, const string& path, bool& justCreated ) {
- OperationContextImpl txn; // TODO get rid of this once reads require transactions
+ Database* DatabaseHolder::getOrCreate(OperationContext* txn, const string& ns, const string& path, bool& justCreated) {
string dbname = _todb( ns );
{
SimpleMutex::scoped_lock lk(_m);
@@ -74,7 +73,7 @@ namespace mongo {
cc().writeHappened();
// this locks _m for defensive checks, so we don't want to be locked right here :
- Database *db = new Database( &txn, dbname.c_str() , justCreated , path );
+ Database *db = new Database(txn, dbname.c_str(), justCreated, path);
{
SimpleMutex::scoped_lock lk(_m);
diff --git a/src/mongo/db/catalog/database_holder.h b/src/mongo/db/catalog/database_holder.h
index a2901926db7..ad40b8601c4 100644
--- a/src/mongo/db/catalog/database_holder.h
+++ b/src/mongo/db/catalog/database_holder.h
@@ -82,7 +82,10 @@ namespace mongo {
return 0;
}
- Database* getOrCreate( const std::string& ns , const std::string& path , bool& justCreated );
+ Database* getOrCreate(OperationContext* txn,
+ const std::string& ns,
+ const std::string& path,
+ bool& justCreated);
void erase( const std::string& ns , const std::string& path ) {
SimpleMutex::scoped_lock lk(_m);