diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-05-28 18:40:59 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-05-28 18:40:59 -0400 |
commit | 8bc2783d2e6e39c0910455b4eac9e0f93a482cfc (patch) | |
tree | 46a523ea698d1a9a80013816d8e568e2fdd2f2dc /src/mongo/db/instance.cpp | |
parent | 0672061deb58aac931912bed68d014247c581968 (diff) | |
download | mongo-8bc2783d2e6e39c0910455b4eac9e0f93a482cfc.tar.gz |
Revert "SERVER-13961 Pass LockState to DBWrite and DBRead directly"
This reverts commit 0672061deb58aac931912bed68d014247c581968.
Diffstat (limited to 'src/mongo/db/instance.cpp')
-rw-r--r-- | src/mongo/db/instance.cpp | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index 373e7f2b3ca..613165ff4d2 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -121,9 +121,8 @@ namespace mongo { QueryMessage q(d); BSONObjBuilder b; - OperationContextImpl txn; const bool isAuthorized = cc().getAuthorizationSession()->isAuthorizedForActionsOnResource( - &txn, ResourcePattern::forClusterResource(), ActionType::inprog); + ResourcePattern::forClusterResource(), ActionType::inprog); audit::logInProgAuthzCheck( &cc(), q.query, isAuthorized ? ErrorCodes::OK : ErrorCodes::Unauthorized); @@ -183,10 +182,8 @@ namespace mongo { DbMessage d(m); QueryMessage q(d); BSONObj obj; - - OperationContextImpl txn; const bool isAuthorized = cc().getAuthorizationSession()->isAuthorizedForActionsOnResource( - &txn, ResourcePattern::forClusterResource(), ActionType::killop); + ResourcePattern::forClusterResource(), ActionType::killop); audit::logKillOpAuthzCheck(&cc(), q.query, isAuthorized ? ErrorCodes::OK : ErrorCodes::Unauthorized); @@ -213,10 +210,8 @@ namespace mongo { bool _unlockFsync(); void unlockFsync(const char *ns, Message& m, DbResponse &dbresponse) { BSONObj obj; - - OperationContextImpl txn; const bool isAuthorized = cc().getAuthorizationSession()->isAuthorizedForActionsOnResource( - &txn, ResourcePattern::forClusterResource(), ActionType::unlock); + ResourcePattern::forClusterResource(), ActionType::unlock); audit::logFsyncUnlockAuthzCheck( &cc(), isAuthorized ? ErrorCodes::OK : ErrorCodes::Unauthorized); if (!isAuthorized) { @@ -254,7 +249,7 @@ namespace mongo { if (!ns.isCommand()) { // Auth checking for Commands happens later. Client* client = &cc(); - Status status = client->getAuthorizationSession()->checkAuthForQuery(txn, ns, q.query); + Status status = client->getAuthorizationSession()->checkAuthForQuery(ns, q.query); audit::logQueryAuthzCheck(client, ns, q.query, status.code()); uassertStatusOK(status); } @@ -346,7 +341,7 @@ namespace mongo { Client& c = cc(); if (!c.isGod()) - c.getAuthorizationSession()->startRequest(txn); + c.getAuthorizationSession()->startRequest(); if ( op == dbQuery ) { if( strstr(ns, ".$cmd") ) { @@ -533,7 +528,7 @@ namespace mongo { verify( n < 30000 ); } - int found = CollectionCursorCache::eraseCursorGlobalIfAuthorized(txn, n, (long long *) x); + int found = CollectionCursorCache::eraseCursorGlobalIfAuthorized(n, (long long *) x); if ( logger::globalLogDomain()->shouldLog(logger::LogSeverity::Debug(1)) || found != n ) { LOG( found == n ? 1 : 0 ) << "killcursors: found " << found << " of " << n << endl; @@ -586,8 +581,7 @@ namespace mongo { bool multi = flags & UpdateOption_Multi; bool broadcast = flags & UpdateOption_Broadcast; - Status status = cc().getAuthorizationSession()->checkAuthForUpdate(txn, - ns, + Status status = cc().getAuthorizationSession()->checkAuthForUpdate(ns, query, toupdate, upsert); @@ -609,7 +603,7 @@ namespace mongo { UpdateExecutor executor(&request, &op.debug()); uassertStatusOK(executor.prepare()); - Lock::DBWrite lk(txn->lockState(), ns.ns()); + Lock::DBWrite lk(ns.ns()); // if this ever moves to outside of lock, need to adjust check // Client::Context::_finishInit @@ -636,7 +630,7 @@ namespace mongo { verify( d.moreJSObjs() ); BSONObj pattern = d.nextJsObj(); - Status status = cc().getAuthorizationSession()->checkAuthForDelete(txn, ns, pattern); + Status status = cc().getAuthorizationSession()->checkAuthForDelete(ns, pattern); audit::logDeleteAuthzCheck(&cc(), ns, pattern, status.code()); uassertStatusOK(status); @@ -649,7 +643,7 @@ namespace mongo { request.setUpdateOpLog(true); DeleteExecutor executor(&request); uassertStatusOK(executor.prepare()); - Lock::DBWrite lk(txn->lockState(), ns.ns()); + Lock::DBWrite lk(ns.ns()); // if this ever moves to outside of lock, need to adjust check Client::Context::_finishInit if ( ! broadcast && handlePossibleShardedMessage( m , 0 ) ) @@ -690,7 +684,7 @@ namespace mongo { uassert( 16258, str::stream() << "Invalid ns [" << ns << "]", nsString.isValid() ); Status status = cc().getAuthorizationSession()->checkAuthForGetMore( - txn, nsString, cursorid); + nsString, cursorid); audit::logGetMoreAuthzCheck(&cc(), nsString, cursorid, status.code()); uassertStatusOK(status); @@ -723,7 +717,7 @@ namespace mongo { // because it may now be out of sync with the client's iteration state. // SERVER-7952 // TODO Temporary code, see SERVER-4563 for a cleanup overview. - CollectionCursorCache::eraseCursorGlobal(txn, cursorid ); + CollectionCursorCache::eraseCursorGlobal( cursorid ); } ex.reset( new AssertionException( e.getInfo().msg, e.getCode() ) ); ok = false; @@ -881,12 +875,12 @@ namespace mongo { // Check auth for insert (also handles checking if this is an index build and checks // for the proper privileges in that case). const NamespaceString nsString(ns); - Status status = cc().getAuthorizationSession()->checkAuthForInsert(txn, nsString, obj); + Status status = cc().getAuthorizationSession()->checkAuthForInsert(nsString, obj); audit::logInsertAuthzCheck(&cc(), nsString, obj, status.code()); uassertStatusOK(status); } - Lock::DBWrite lk(txn->lockState(), ns); + Lock::DBWrite lk(ns); // CONCURRENCY TODO: is being read locked in big log sufficient here? // writelock is used to synchronize stepdowns w/ writes @@ -930,7 +924,7 @@ namespace mongo { local database does NOT count except for rsoplog collection. used to set the hasData field on replset heartbeat command response */ - bool replHasDatabases(OperationContext* txn) { + bool replHasDatabases() { vector<string> names; getDatabaseNames(names); if( names.size() >= 2 ) return true; @@ -939,7 +933,7 @@ namespace mongo { return true; // we have a local database. return true if oplog isn't empty { - Lock::DBRead lk(txn->lockState(), repl::rsoplog); + Lock::DBRead lk(repl::rsoplog); BSONObj o; if( Helpers::getFirst(repl::rsoplog, o) ) return true; @@ -1008,9 +1002,7 @@ namespace { } void DBDirectClient::killCursor( long long id ) { - // The killCursor command on the DB client is only used by sharding, - // so no need to have it for MongoD. - verify(!"killCursor should not be used in MongoD"); + CollectionCursorCache::eraseCursorGlobal( id ); } HostAndPort DBDirectClient::_clientHost = HostAndPort( "0.0.0.0" , 0 ); @@ -1021,9 +1013,7 @@ namespace { << " to zero in query: " << query << endl; skip = 0; } - - OperationContextImpl txn; - Lock::DBRead lk(txn.lockState(), ns); + Lock::DBRead lk( ns ); string errmsg; int errCode; long long res = runCount( ns, _countCmd( ns , query , options , limit , skip ) , errmsg, errCode ); |