diff options
author | Hari Khalsa <hkhalsa@10gen.com> | 2014-08-26 16:55:17 -0400 |
---|---|---|
committer | Hari Khalsa <hkhalsa@10gen.com> | 2014-09-04 15:31:53 -0400 |
commit | 722b37791dc3adececd74894ccb61e3da64ea94e (patch) | |
tree | a68e9b61f4b59716d4c2fcd7b17519a1f19bc60d | |
parent | c14c1f113d56da4e32ac13a123028c916f0c8cff (diff) | |
download | mongo-722b37791dc3adececd74894ccb61e3da64ea94e.tar.gz |
SERVER-14668 remove some usages of cc()
-rw-r--r-- | src/mongo/db/catalog/collection_cursor_cache.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/catalog/database_holder.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/commands.h | 1 | ||||
-rw-r--r-- | src/mongo/db/commands/count.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/commands/get_last_error.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/commands/write_commands/batch_executor.cpp | 23 | ||||
-rw-r--r-- | src/mongo/db/commands/write_commands/batch_executor.h | 6 | ||||
-rw-r--r-- | src/mongo/db/commands/write_commands/write_commands.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/db.cpp | 16 | ||||
-rw-r--r-- | src/mongo/db/dbcommands.cpp | 21 | ||||
-rw-r--r-- | src/mongo/db/dbhelpers.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/dbwebserver.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/index_builder.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/index_rebuilder.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/instance.cpp | 53 | ||||
-rw-r--r-- | src/mongo/db/range_deleter_db_env.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/repl/heartbeat.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/repl_coordinator_legacy.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/restapi.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/s_only.cpp | 3 |
20 files changed, 65 insertions, 99 deletions
diff --git a/src/mongo/db/catalog/collection_cursor_cache.cpp b/src/mongo/db/catalog/collection_cursor_cache.cpp index 241a3866415..f6c2a7793b7 100644 --- a/src/mongo/db/catalog/collection_cursor_cache.cpp +++ b/src/mongo/db/catalog/collection_cursor_cache.cpp @@ -176,7 +176,7 @@ namespace mongo { NamespaceString nss( ns ); if ( checkAuth ) { - AuthorizationSession* as = cc().getAuthorizationSession(); + AuthorizationSession* as = txn->getClient()->getAuthorizationSession(); bool isAuthorized = as->isAuthorizedForActionsOnNamespace( nss, ActionType::killCursors); if ( !isAuthorized ) { diff --git a/src/mongo/db/catalog/database_holder.cpp b/src/mongo/db/catalog/database_holder.cpp index 2498c72cd8c..1b5d20da12d 100644 --- a/src/mongo/db/catalog/database_holder.cpp +++ b/src/mongo/db/catalog/database_holder.cpp @@ -112,7 +112,8 @@ namespace mongo { // we mark our thread as having done writes now as we do not want any exceptions // once we start creating a new database - cc().writeHappened(); + // TODO(Mathias): Remove this when rollback is enabled. + txn->getClient()->writeHappened(); // this locks _m for defensive checks, so we don't want to be locked right here : StorageEngine* storageEngine = getGlobalEnvironment()->getGlobalStorageEngine(); diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h index e8c1a91d5b5..ac56a808d01 100644 --- a/src/mongo/db/commands.h +++ b/src/mongo/db/commands.h @@ -234,7 +234,6 @@ namespace mutablebson { // For mongod and webserver. static void execCommand(OperationContext* txn, Command* c, - Client& client, int queryOptions, const char *ns, BSONObj& cmdObj, diff --git a/src/mongo/db/commands/count.cpp b/src/mongo/db/commands/count.cpp index df0ec5fe62c..01c0638b9ea 100644 --- a/src/mongo/db/commands/count.cpp +++ b/src/mongo/db/commands/count.cpp @@ -104,12 +104,10 @@ namespace mongo { scoped_ptr<PlanExecutor> exec(rawExec); // Store the plan summary string in CurOp. - Client& client = cc(); - CurOp* currentOp = client.curop(); - if (NULL != currentOp) { + if (NULL != txn->getCurOp()) { PlanSummaryStats stats; Explain::getSummaryStats(exec.get(), &stats); - currentOp->debug().planSummary = stats.summaryStr.c_str(); + txn->getCurOp()->debug().planSummary = stats.summaryStr.c_str(); } try { diff --git a/src/mongo/db/commands/get_last_error.cpp b/src/mongo/db/commands/get_last_error.cpp index 773d2483172..cd85a3a2a6f 100644 --- a/src/mongo/db/commands/get_last_error.cpp +++ b/src/mongo/db/commands/get_last_error.cpp @@ -124,7 +124,7 @@ namespace mongo { LastError *le = lastError.disableForCommand(); // Always append lastOp and connectionId - Client& c = cc(); + Client& c = *txn->getClient(); c.appendLastOp( result ); // for sharding; also useful in general for debugging @@ -142,7 +142,7 @@ namespace mongo { bool lastOpTimePresent = extracted != FieldParser::FIELD_NONE; if (!lastOpTimePresent) { // Use the client opTime if no wOpTime is specified - lastOpTime = cc().getLastOp(); + lastOpTime = c.getLastOp(); } OID electionId; diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp index 34ef43b0872..efada43e780 100644 --- a/src/mongo/db/commands/write_commands/batch_executor.cpp +++ b/src/mongo/db/commands/write_commands/batch_executor.cpp @@ -98,12 +98,10 @@ namespace mongo { WriteBatchExecutor::WriteBatchExecutor( OperationContext* txn, const BSONObj& wc, - Client* client, OpCounters* opCounters, LastError* le ) : _txn(txn), _defaultWriteConcern( wc ), - _client( client ), _opCounters( opCounters ), _le( le ), _stats( new WriteBatchStats ) { @@ -262,10 +260,10 @@ namespace mongo { if ( needToEnforceWC ) { - _client->curop()->setMessage( "waiting for write concern" ); + _txn->getCurOp()->setMessage( "waiting for write concern" ); WriteConcernResult res; - Status status = waitForWriteConcern( _txn, writeConcern, _client->getLastOp(), &res ); + Status status = waitForWriteConcern( _txn, writeConcern, _txn->getClient()->getLastOp(), &res ); if ( !status.isOK() ) { wcError.reset( toWriteConcernError( status, res ) ); @@ -364,7 +362,7 @@ namespace mongo { repl::ReplicationCoordinator* replCoord = repl::getGlobalReplicationCoordinator(); const repl::ReplicationCoordinator::Mode replMode = replCoord->getReplicationMode(); if (replMode != repl::ReplicationCoordinator::modeNone) { - response->setLastOp( _client->getLastOp() ); + response->setLastOp( _txn->getClient()->getLastOp() ); if (replMode == repl::ReplicationCoordinator::modeReplSet) { response->setElectionId(replCoord->getElectionId()); } @@ -593,7 +591,6 @@ namespace mongo { } static void finishCurrentOp( OperationContext* txn, - Client* client, CurOp* currentOp, WriteErrorDetail* opError ) { @@ -618,7 +615,7 @@ namespace mongo { } if ( currentOp->shouldDBProfile( executionTime ) ) { - profile( txn, *client, currentOp->getOp(), *currentOp ); + profile( txn, *txn->getClient(), currentOp->getOp(), *currentOp ); } } @@ -853,7 +850,7 @@ namespace mongo { WriteErrorDetail** error ) { // BEGIN CURRENT OP - scoped_ptr<CurOp> currentOp( beginCurrentOp( _client, updateItem ) ); + scoped_ptr<CurOp> currentOp( beginCurrentOp( _txn->getClient(), updateItem ) ); incOpStats( updateItem ); WriteOpResult result; @@ -865,7 +862,7 @@ namespace mongo { } // END CURRENT OP incWriteStats( updateItem, result.getStats(), result.getError(), currentOp.get() ); - finishCurrentOp( _txn, _client, currentOp.get(), result.getError() ); + finishCurrentOp( _txn, currentOp.get(), result.getError() ); if ( result.getError() ) { result.getError()->setIndex( updateItem.getItemIndex() ); @@ -879,7 +876,7 @@ namespace mongo { // Removes are similar to updates, but page faults are handled externally // BEGIN CURRENT OP - scoped_ptr<CurOp> currentOp( beginCurrentOp( _client, removeItem ) ); + scoped_ptr<CurOp> currentOp( beginCurrentOp( _txn->getClient(), removeItem ) ); incOpStats( removeItem ); WriteOpResult result; @@ -888,7 +885,7 @@ namespace mongo { // END CURRENT OP incWriteStats( removeItem, result.getStats(), result.getError(), currentOp.get() ); - finishCurrentOp( _txn, _client, currentOp.get(), result.getError() ); + finishCurrentOp( _txn, currentOp.get(), result.getError() ); if ( result.getError() ) { result.getError()->setIndex( removeItem.getItemIndex() ); @@ -1001,7 +998,7 @@ namespace mongo { void WriteBatchExecutor::execOneInsert(ExecInsertsState* state, WriteErrorDetail** error) { BatchItemRef currInsertItem(state->request, state->currIndex); - scoped_ptr<CurOp> currentOp(beginCurrentOp(_client, currInsertItem)); + scoped_ptr<CurOp> currentOp(beginCurrentOp(_txn->getClient(), currInsertItem)); incOpStats(currInsertItem); WriteOpResult result; @@ -1021,7 +1018,7 @@ namespace mongo { result.getStats(), result.getError(), currentOp.get()); - finishCurrentOp(_txn, _client, currentOp.get(), result.getError()); + finishCurrentOp(_txn, currentOp.get(), result.getError()); if (result.getError()) { *error = result.releaseError(); diff --git a/src/mongo/db/commands/write_commands/batch_executor.h b/src/mongo/db/commands/write_commands/batch_executor.h index fcb55f2b6b6..82380962c17 100644 --- a/src/mongo/db/commands/write_commands/batch_executor.h +++ b/src/mongo/db/commands/write_commands/batch_executor.h @@ -31,7 +31,6 @@ #include <string> #include "mongo/base/disallow_copying.h" -#include "mongo/db/client.h" #include "mongo/s/write_ops/batched_command_request.h" #include "mongo/s/write_ops/batched_command_response.h" #include "mongo/s/write_ops/batched_delete_document.h" @@ -61,7 +60,6 @@ namespace mongo { WriteBatchExecutor( OperationContext* txn, const BSONObj& defaultWriteConcern, - Client* client, OpCounters* opCounters, LastError* le ); @@ -139,10 +137,6 @@ namespace mongo { // Default write concern, if one isn't provide in the batches. const BSONObj _defaultWriteConcern; - // Client object to issue writes on behalf of. - // Not owned here. - Client* _client; - // OpCounters object to update - needed for stats reporting // Not owned here. OpCounters* _opCounters; diff --git a/src/mongo/db/commands/write_commands/write_commands.cpp b/src/mongo/db/commands/write_commands/write_commands.cpp index d9ce37c626a..28a9bcfd619 100644 --- a/src/mongo/db/commands/write_commands/write_commands.cpp +++ b/src/mongo/db/commands/write_commands/write_commands.cpp @@ -129,7 +129,6 @@ namespace mongo { WriteBatchExecutor writeBatchExecutor(txn, defaultWriteConcern, - &cc(), &globalOpCounters, lastError.get()); diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index 1e41cb30367..cd50faab39f 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -526,18 +526,6 @@ namespace mongo { } memJournalServerStatusMetric; } - -#if 0 // TODO SERVER-14143 figure out something better. For now just disabling js interruption. - const char * jsInterruptCallback() { - // should be safe to interrupt in js code, even if we have a write lock - return killCurrentOp.checkForInterruptNoAssert(); - } - - unsigned jsGetCurrentOpIdCallback() { - return cc().curop()->opNum(); - } -#endif - static void _initAndListen(int listenPort ) { Client::initThread("initandlisten"); @@ -605,10 +593,6 @@ namespace mongo { if (mongodGlobalParams.scriptingEnabled) { ScriptEngine::setup(); -#if 0 // TODO SERVER-14143 figure out something better. For now just disabling js interruption. - globalScriptEngine->setCheckInterruptCallback( jsInterruptCallback ); - globalScriptEngine->setGetCurrentOpIdCallback( jsGetCurrentOpIdCallback ); -#endif } // On replica set members we only clear temp collections on DBs other than "local" during diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp index 6c07ee0c21a..4b65ba7b6c1 100644 --- a/src/mongo/db/dbcommands.cpp +++ b/src/mongo/db/dbcommands.cpp @@ -1242,7 +1242,6 @@ namespace mongo { */ void Command::execCommand(OperationContext* txn, Command * c , - Client& client, int queryOptions, const char *cmdns, BSONObj& cmdObj, @@ -1252,7 +1251,7 @@ namespace mongo { scoped_ptr<MaintenanceModeSetter> mmSetter; if ( cmdObj["help"].trueValue() ) { - client.curop()->ensureStarted(); + txn->getCurOp()->ensureStarted(); stringstream ss; ss << "help for: " << c->name << " "; c->help( ss ); @@ -1267,7 +1266,7 @@ namespace mongo { // in that code path that must not see the impersonated user and roles array elements. std::vector<UserName> parsedUserNames; std::vector<RoleName> parsedRoleNames; - AuthorizationSession* authSession = client.getAuthorizationSession(); + AuthorizationSession* authSession = txn->getClient()->getAuthorizationSession(); bool rolesFieldIsPresent = false; bool usersFieldIsPresent = false; audit::parseAndRemoveImpersonatedRolesField(cmdObj, @@ -1291,7 +1290,7 @@ namespace mongo { parsedUserNames, parsedRoleNames); - Status status = _checkAuthorization(c, &client, dbname, cmdObj, fromRepl); + Status status = _checkAuthorization(c, txn->getClient(), dbname, cmdObj, fromRepl); if (!status.isOK()) { appendCommandStatus(result, status); return; @@ -1323,7 +1322,7 @@ namespace mongo { LOG( 2 ) << "command: " << cmdObj << endl; } - client.curop()->setCommand(c); + txn->getCurOp()->setCommand(c); if (c->maintenanceMode() && repl::getGlobalReplicationCoordinator()->getReplicationMode() == @@ -1351,8 +1350,8 @@ namespace mongo { return; } - client.curop()->setMaxTimeMicros(static_cast<unsigned long long>(maxTimeMS.getValue()) - * 1000); + txn->getCurOp()->setMaxTimeMicros(static_cast<unsigned long long>(maxTimeMS.getValue()) + * 1000); try { txn->checkForInterrupt(); // May trigger maxTimeAlwaysTimeOut fail point. } @@ -1364,7 +1363,7 @@ namespace mongo { std::string errmsg; bool retval = false; - client.curop()->ensureStarted(); + txn->getCurOp()->ensureStarted(); retval = _execCommand(txn, c, dbname, cmdObj, queryOptions, errmsg, result, fromRepl); @@ -1375,7 +1374,7 @@ namespace mongo { // Detect mongos connections by looking for setShardVersion to have been run previously // on this connection. if (shardingState.needCollectionMetadata(dbname)) { - appendGLEHelperData(result, client.getLastOp(), replCoord->getElectionId()); + appendGLEHelperData(result, txn->getClient()->getLastOp(), replCoord->getElectionId()); } } return; @@ -1433,14 +1432,12 @@ namespace mongo { queryOptions |= QueryOption_SlaveOk; } - Client& client = cc(); - BSONElement e = jsobj.firstElement(); Command * c = e.type() ? Command::findCommand( e.fieldName() ) : 0; if ( c ) { - Command::execCommand(txn, c, client, queryOptions, ns, jsobj, anObjBuilder, fromRepl); + Command::execCommand(txn, c, queryOptions, ns, jsobj, anObjBuilder, fromRepl); } else { Command::appendCommandStatus(anObjBuilder, diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp index 2ebffc2c553..9a2be8a7599 100644 --- a/src/mongo/db/dbhelpers.cpp +++ b/src/mongo/db/dbhelpers.cpp @@ -355,8 +355,6 @@ namespace mongo { << "begin removal of " << min << " to " << max << " in " << ns << " with write concern: " << writeConcern.toBSON() << endl; - Client& c = cc(); - long long numDeleted = 0; long long millisWaitingForReplication = 0; @@ -452,7 +450,7 @@ namespace mongo { if (writeConcern.shouldWaitForOtherNodes() && numDeleted > 0) { repl::ReplicationCoordinator::StatusAndDuration replStatus = repl::getGlobalReplicationCoordinator()->awaitReplication(txn, - c.getLastOp(), + txn->getClient()->getLastOp(), writeConcern); if (replStatus.status.code() == ErrorCodes::ExceededTimeLimit) { warning(LogComponent::kSharding) diff --git a/src/mongo/db/dbwebserver.cpp b/src/mongo/db/dbwebserver.cpp index ccf9c5ffaee..de76f6f502b 100644 --- a/src/mongo/db/dbwebserver.cpp +++ b/src/mongo/db/dbwebserver.cpp @@ -552,10 +552,9 @@ namespace mongo { verify( c ); BSONObj cmdObj = BSON( cmd << 1 ); - Client& client = cc(); BSONObjBuilder result; - Command::execCommand(txn, c, client, 0, "admin.", cmdObj , result, false); + Command::execCommand(txn, c, 0, "admin.", cmdObj , result, false); responseCode = 200; diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp index 219a10a25b8..9da3a776003 100644 --- a/src/mongo/db/index_builder.cpp +++ b/src/mongo/db/index_builder.cpp @@ -68,7 +68,7 @@ namespace mongo { repl::replLocalAuth(); - cc().curop()->reset(HostAndPort(), dbInsert); + txn.getCurOp()->reset(HostAndPort(), dbInsert); NamespaceString ns(_index["ns"].String()); Client::WriteContext ctx(&txn, ns.getSystemIndexesCollection()); @@ -80,7 +80,7 @@ namespace mongo { } ctx.commit(); - cc().shutdown(); + txn.getClient()->shutdown(); } Status IndexBuilder::buildInForeground(OperationContext* txn, Database* db) const { diff --git a/src/mongo/db/index_rebuilder.cpp b/src/mongo/db/index_rebuilder.cpp index 34cb8fcc597..cbde00dbf04 100644 --- a/src/mongo/db/index_rebuilder.cpp +++ b/src/mongo/db/index_rebuilder.cpp @@ -137,7 +137,7 @@ namespace { void restartInProgressIndexesFromLastShutdown() { OperationContextImpl txn; - cc().getAuthorizationSession()->grantInternalAuthorization(); + txn.getClient()->getAuthorizationSession()->grantInternalAuthorization(); std::vector<std::string> dbNames; diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index f2a2470f0e1..3f47051c03d 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -120,11 +120,11 @@ namespace mongo { QueryMessage q(d); BSONObjBuilder b; - const bool isAuthorized = cc().getAuthorizationSession()->isAuthorizedForActionsOnResource( + const bool isAuthorized = txn->getClient()->getAuthorizationSession()->isAuthorizedForActionsOnResource( ResourcePattern::forClusterResource(), ActionType::inprog); audit::logInProgAuthzCheck( - &cc(), q.query, isAuthorized ? ErrorCodes::OK : ErrorCodes::Unauthorized); + txn->getClient(), q.query, isAuthorized ? ErrorCodes::OK : ErrorCodes::Unauthorized); if (!isAuthorized) { b.append("err", "unauthorized"); @@ -148,7 +148,7 @@ namespace mongo { const NamespaceString nss(d.getns()); - Client& me = cc(); + Client& me = *txn->getClient(); scoped_lock bl(Client::clientsMutex); Matcher m(filter, WhereCallbackReal(txn, nss.db())); for( set<Client*>::iterator i = Client::clients.begin(); i != Client::clients.end(); i++ ) { @@ -182,14 +182,14 @@ namespace mongo { replyToQuery(0, m, dbresponse, b.obj()); } - void killOp( Message &m, DbResponse &dbresponse ) { + void killOp( OperationContext* txn, Message &m, DbResponse &dbresponse ) { DbMessage d(m); QueryMessage q(d); BSONObj obj; - const bool isAuthorized = cc().getAuthorizationSession()->isAuthorizedForActionsOnResource( + const bool isAuthorized = txn->getClient()->getAuthorizationSession()->isAuthorizedForActionsOnResource( ResourcePattern::forClusterResource(), ActionType::killop); - audit::logKillOpAuthzCheck(&cc(), + audit::logKillOpAuthzCheck(txn->getClient(), q.query, isAuthorized ? ErrorCodes::OK : ErrorCodes::Unauthorized); if (!isAuthorized) { @@ -213,13 +213,13 @@ namespace mongo { } bool _unlockFsync(); - static void unlockFsync(const char *ns, Message& m, DbResponse &dbresponse) { + static void unlockFsync(OperationContext* txn, const char *ns, Message& m, DbResponse &dbresponse) { BSONObj obj; - const bool isAuthorized = cc().getAuthorizationSession()->isAuthorizedForActionsOnResource( + const bool isAuthorized = txn->getClient()->getAuthorizationSession()->isAuthorizedForActionsOnResource( ResourcePattern::forClusterResource(), ActionType::unlock); audit::logFsyncUnlockAuthzCheck( - &cc(), isAuthorized ? ErrorCodes::OK : ErrorCodes::Unauthorized); + txn->getClient(), isAuthorized ? ErrorCodes::OK : ErrorCodes::Unauthorized); if (!isAuthorized) { obj = fromjson("{\"err\":\"unauthorized\"}"); } @@ -254,7 +254,7 @@ namespace mongo { NamespaceString ns(d.getns()); if (!ns.isCommand()) { // Auth checking for Commands happens later. - Client* client = &cc(); + Client* client = txn->getClient(); Status status = client->getAuthorizationSession()->checkAuthForQuery(ns, q.query); audit::logQueryAuthzCheck(client, ns, q.query, status.code()); uassertStatusOK(status); @@ -345,7 +345,7 @@ namespace mongo { DbMessage dbmsg(m); - Client& c = cc(); + Client& c = *txn->getClient(); if (!txn->isGod()) { c.getAuthorizationSession()->startRequest(txn); @@ -365,11 +365,11 @@ namespace mongo { return; } if( strstr(ns, "$cmd.sys.killop") ) { - killOp(m, dbresponse); + killOp(txn, m, dbresponse); return; } if( strstr(ns, "$cmd.sys.unlock") ) { - unlockFsync(ns, m, dbresponse); + unlockFsync(txn, ns, m, dbresponse); return; } } @@ -591,11 +591,11 @@ namespace mongo { bool multi = flags & UpdateOption_Multi; bool broadcast = flags & UpdateOption_Broadcast; - Status status = cc().getAuthorizationSession()->checkAuthForUpdate(ns, + Status status = txn->getClient()->getAuthorizationSession()->checkAuthForUpdate(ns, query, toupdate, upsert); - audit::logUpdateAuthzCheck(&cc(), ns, query, toupdate, upsert, multi, status.code()); + audit::logUpdateAuthzCheck(txn->getClient(), ns, query, toupdate, upsert, multi, status.code()); uassertStatusOK(status); op.debug().query = query; @@ -633,8 +633,8 @@ namespace mongo { verify( d.moreJSObjs() ); BSONObj pattern = d.nextJsObj(); - Status status = cc().getAuthorizationSession()->checkAuthForDelete(ns, pattern); - audit::logDeleteAuthzCheck(&cc(), ns, pattern, status.code()); + Status status = txn->getClient()->getAuthorizationSession()->checkAuthForDelete(ns, pattern); + audit::logDeleteAuthzCheck(txn->getClient(), ns, pattern, status.code()); uassertStatusOK(status); op.debug().query = pattern; @@ -682,9 +682,9 @@ namespace mongo { const NamespaceString nsString( ns ); uassert( 16258, str::stream() << "Invalid ns [" << ns << "]", nsString.isValid() ); - Status status = cc().getAuthorizationSession()->checkAuthForGetMore( + Status status = txn->getClient()->getAuthorizationSession()->checkAuthForGetMore( nsString, cursorid); - audit::logGetMoreAuthzCheck(&cc(), nsString, cursorid, status.code()); + audit::logGetMoreAuthzCheck(txn->getClient(), nsString, cursorid, status.code()); uassertStatusOK(status); if (str::startsWith(ns, "local.oplog.")){ @@ -897,8 +897,8 @@ namespace mongo { // Check auth for insert (also handles checking if this is an index build and checks // for the proper privileges in that case). - Status status = cc().getAuthorizationSession()->checkAuthForInsert(nsString, obj); - audit::logInsertAuthzCheck(&cc(), nsString, obj, status.code()); + Status status = txn->getClient()->getAuthorizationSession()->checkAuthForInsert(nsString, obj); + audit::logInsertAuthzCheck(txn->getClient(), nsString, obj, status.code()); uassertStatusOK(status); } @@ -939,17 +939,18 @@ namespace { class GodScope { MONGO_DISALLOW_COPYING(GodScope); public: - GodScope() { - _prev = cc().setGod(true); + GodScope(OperationContext* txn) : _txn(txn) { + _prev = _txn->getClient()->setGod(true); } - ~GodScope() { cc().setGod(_prev); } + ~GodScope() { _txn->getClient()->setGod(_prev); } private: bool _prev; + OperationContext* _txn; }; } // namespace bool DBDirectClient::call( Message &toSend, Message &response, bool assertOk , string * actualServer ) { - GodScope gs; + GodScope gs(_txn); if ( lastError._get() ) lastError.startRequest( toSend, lastError._get() ); DbResponse dbResponse; @@ -961,7 +962,7 @@ namespace { } void DBDirectClient::say( Message &toSend, bool isRetry, string * actualServer ) { - GodScope gs; + GodScope gs(_txn); if ( lastError._get() ) lastError.startRequest( toSend, lastError._get() ); DbResponse dbResponse; diff --git a/src/mongo/db/range_deleter_db_env.cpp b/src/mongo/db/range_deleter_db_env.cpp index 52d9ee3c9ec..8b75c7881fb 100644 --- a/src/mongo/db/range_deleter_db_env.cpp +++ b/src/mongo/db/range_deleter_db_env.cpp @@ -116,7 +116,7 @@ namespace mongo { warning() << *errMsg << endl; if (!initiallyHaveClient) { - cc().shutdown(); + txn->getClient()->shutdown(); } return false; @@ -136,7 +136,7 @@ namespace mongo { << ", cause by:" << causedBy(ex); if (!initiallyHaveClient) { - cc().shutdown(); + txn->getClient()->shutdown(); } return false; @@ -144,7 +144,7 @@ namespace mongo { } if (!initiallyHaveClient) { - cc().shutdown(); + txn->getClient()->shutdown(); } return true; diff --git a/src/mongo/db/repl/heartbeat.cpp b/src/mongo/db/repl/heartbeat.cpp index 3ef57c25955..64dc14ff256 100644 --- a/src/mongo/db/repl/heartbeat.cpp +++ b/src/mongo/db/repl/heartbeat.cpp @@ -120,7 +120,7 @@ namespace { /* we want to keep heartbeat connections open when relinquishing primary. tag them here. */ { - AbstractMessagingPort *mp = cc().port(); + AbstractMessagingPort *mp = txn->getClient()->port(); if( mp ) mp->tag |= ScopedConn::keepOpen; } diff --git a/src/mongo/db/repl/repl_coordinator_legacy.cpp b/src/mongo/db/repl/repl_coordinator_legacy.cpp index 44032d2ebae..eab110ed6b2 100644 --- a/src/mongo/db/repl/repl_coordinator_legacy.cpp +++ b/src/mongo/db/repl/repl_coordinator_legacy.cpp @@ -183,7 +183,7 @@ namespace repl { LegacyReplicationCoordinator::awaitReplicationOfLastOp( const OperationContext* txn, const WriteConcernOptions& writeConcern) { - return awaitReplication(txn, cc().getLastOp(), writeConcern); + return awaitReplication(txn, txn->getClient()->getLastOp(), writeConcern); } Status LegacyReplicationCoordinator::stepDown(OperationContext* txn, diff --git a/src/mongo/db/restapi.cpp b/src/mongo/db/restapi.cpp index c1d5c329773..e419aa0ccf9 100644 --- a/src/mongo/db/restapi.cpp +++ b/src/mongo/db/restapi.cpp @@ -265,7 +265,7 @@ namespace mongo { } restHandler; bool RestAdminAccess::haveAdminUsers(OperationContext* txn) const { - AuthorizationSession* authzSession = cc().getAuthorizationSession(); + AuthorizationSession* authzSession = txn->getClient()->getAuthorizationSession(); return authzSession->getAuthorizationManager().hasAnyPrivilegeDocuments(txn); } diff --git a/src/mongo/s/s_only.cpp b/src/mongo/s/s_only.cpp index ed5aa2568e2..3db331d2dbf 100644 --- a/src/mongo/s/s_only.cpp +++ b/src/mongo/s/s_only.cpp @@ -103,13 +103,12 @@ namespace mongo { // execCommand and not need to worry if it's in a mongod or mongos. void Command::execCommand(OperationContext* txn, Command * c, - Client& client, int queryOptions, const char *ns, BSONObj& cmdObj, BSONObjBuilder& result, bool fromRepl ) { - execCommandClientBasic(txn, c, client, queryOptions, ns, cmdObj, result, fromRepl); + execCommandClientBasic(txn, c, *txn->getClient(), queryOptions, ns, cmdObj, result, fromRepl); } void Command::execCommandClientBasic(OperationContext* txn, |