From 7cd9cf303c824478f0f6d60cadfcc1a25bdb21f2 Mon Sep 17 00:00:00 2001 From: Andy Schwerin Date: Fri, 27 Feb 2015 18:33:28 -0500 Subject: SERVER-17310 Make mongo::mutex a typedef of boost::mutex and remove mongo::scoped_lock. --- src/mongo/db/commands/dbhash.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/mongo/db/commands/dbhash.cpp') diff --git a/src/mongo/db/commands/dbhash.cpp b/src/mongo/db/commands/dbhash.cpp index 9d42024210d..bf0f43dcc9b 100644 --- a/src/mongo/db/commands/dbhash.cpp +++ b/src/mongo/db/commands/dbhash.cpp @@ -62,9 +62,7 @@ namespace mongo { // ---- - DBHashCmd::DBHashCmd() - : Command( "dbHash", false, "dbhash" ), - _cachedHashedMutex( "_cachedHashedMutex" ){ + DBHashCmd::DBHashCmd() : Command("dbHash", false, "dbhash") { } void DBHashCmd::addRequiredPrivileges(const std::string& dbname, @@ -75,11 +73,14 @@ namespace mongo { out->push_back(Privilege(ResourcePattern::forDatabaseName(dbname), actions)); } - string DBHashCmd::hashCollection( OperationContext* opCtx, Database* db, const string& fullCollectionName, bool* fromCache ) { - scoped_ptr cachedHashedLock; + std::string DBHashCmd::hashCollection(OperationContext* opCtx, + Database* db, + const std::string& fullCollectionName, + bool* fromCache) { + boost::unique_lock cachedHashedLock(_cachedHashedMutex, boost::defer_lock); if ( isCachable( fullCollectionName ) ) { - cachedHashedLock.reset( new scoped_lock( _cachedHashedMutex ) ); + cachedHashedLock.lock(); string hash = _cachedHashed[fullCollectionName]; if ( hash.size() > 0 ) { *fromCache = true; @@ -133,7 +134,7 @@ namespace mongo { md5_finish(&st, d); string hash = digestToString( d ); - if ( cachedHashedLock.get() ) { + if (cachedHashedLock.owns_lock()) { _cachedHashed[fullCollectionName] = hash; } @@ -225,7 +226,7 @@ namespace mongo { } void commit() { - scoped_lock lk( _dCmd->_cachedHashedMutex ); + boost::lock_guard lk( _dCmd->_cachedHashedMutex ); _dCmd->_cachedHashed.erase(_ns); } void rollback() { } -- cgit v1.2.1