void Lock::DBWrite::lockDB(const string& ns) { fassert( 16253, !ns.empty() ); Acquiring a(this, *_lockState); _locked_W=false; _locked_w=false; _weLocked=0; massert(16186, "can't get a DBWrite while having a read lock", !_lockState->hasAnyReadLock()); if (_lockState->isW()) return; StringData db = nsToDatabaseSubstring( ns ); Nestable nested = n(db); if( nested == admin ) { // we can't nestedly lock both admin and local as implemented. so lock_W. qlk.lock_W(_lockState); _locked_W = true; return; } if( !nested ) lockOther(db); lockTop(); if( nested ) lockNestable(nested); }
void Lock::DBWrite::lockDB(const string& ns, const string &context) { fassert( 16253, !ns.empty() ); LockState& ls = lockState(); Acquiring a(this,ls); _locked_W=false; _locked_w=false; _weLocked=0; massert( 16186 , "can't get a DBWrite while having a read lock" , ! ls.hasAnyReadLock() ); if( ls.isW() ) return; if (DB_LEVEL_LOCKING_ENABLED) { StringData db = nsToDatabaseSubstring( ns ); Nestable nested = n(db); if( nested == admin ) { // we can't nestedly lock both admin and local as implemented. so lock_W. qlk.lock_W(); _locked_W = true; return; } if( !nested ) lockOther(db, context); lockTop(ls); if( nested ) lockNestable(nested, context); } else { qlk.lock_W(); _locked_w = true; } }
void Lock::DBRead::lockDB(const string& ns) { fassert( 16254, !ns.empty() ); LockState& ls = lockState(); Acquiring a(this,ls); _locked_r=false; _weLocked=0; if ( ls.isRW() ) return; if (DB_LEVEL_LOCKING_ENABLED) { char db[MaxDatabaseNameLen]; nsToDatabase(ns.data(), db); Nestable nested = n(db); if( !nested ) lockOther(db); lockTop(ls); if( nested ) lockNestable(nested); } else { qlk.lock_R(); _locked_r = true; } }
void Lock::DBRead::lockDB(const string& ns) { fassert( 16254, !ns.empty() ); Acquiring a(this, *_lockState); _locked_r=false; _weLocked=0; if (_lockState->isRW()) return; StringData db = nsToDatabaseSubstring(ns); Nestable nested = n(db); if( !nested ) lockOther(db); lockTop(); if( nested ) lockNestable(nested); }
void Lock::DBRead::lockDB(const string& ns, const string &context) { fassert( 16254, !ns.empty() ); LockState& ls = lockState(); Acquiring a(this,ls); _locked_r=false; _weLocked=0; if ( ls.isRW() ) return; if (DB_LEVEL_LOCKING_ENABLED) { StringData db = nsToDatabaseSubstring(ns); Nestable nested = n(db); if( !nested ) lockOther(db, context); lockTop(ls); if( nested ) lockNestable(nested, context); } else { qlk.lock_R(); _locked_r = true; } }