From 7849434abe5c8c24c7dd6dc7e664ebf1069c2557 Mon Sep 17 00:00:00 2001 From: Jason Rassi Date: Tue, 4 Nov 2014 11:44:52 -0500 Subject: SERVER-15541 Clean up some usages of WriteUnitOfWork Removes some WriteUnitOfWork objects where they are unneeded, and moves the declaration of some existing WriteUnitOfWork objects to limit their scope to the write being performed (so that yield-capable reads are not inside them). --- src/mongo/db/introspect.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/mongo/db/introspect.cpp') diff --git a/src/mongo/db/introspect.cpp b/src/mongo/db/introspect.cpp index 1359abf0375..bbd5cf6c71a 100644 --- a/src/mongo/db/introspect.cpp +++ b/src/mongo/db/introspect.cpp @@ -126,14 +126,17 @@ namespace { p = b.done(); } + WriteUnitOfWork wunit(txn); + // write: not replicated // get or create the profiling collection Collection* profileCollection = getOrCreateProfileCollection(txn, db); - if ( profileCollection ) { - profileCollection->insertDocument( txn, p, false ); - return true; + if ( !profileCollection ) { + return false; } - return false; + profileCollection->insertDocument( txn, p, false ); + wunit.commit(); + return true; } void profile(OperationContext* txn, const Client& c, int op, CurOp& currentOp) { @@ -157,9 +160,7 @@ namespace { } Database* db = dbHolder().get(txn, dbname); if (db != NULL) { - // We want the profiling to happen in a different WUOW from the actual op. Lock::CollectionLock clk(txn->lockState(), db->getProfilingNS(), MODE_X); - WriteUnitOfWork wunit(txn); Client::Context cx(txn, currentOp.getNS(), false); if ( !_profile(txn, c, cx.db(), currentOp, profileBufBuilder ) && lk.get() ) { if ( tryAgain ) { @@ -170,7 +171,6 @@ namespace { tryAgain = true; continue; } - wunit.commit(); } else { mongo::log() << "note: not profiling because db went away - " -- cgit v1.2.1