bool AuthzManagerExternalStateMongos::tryAcquireAuthzUpdateLock(const StringData& why) { boost::lock_guard<boost::mutex> lkLocal(_distLockGuard); if (_authzDataUpdateLock.get()) { return false; } // Temporarily put into an auto_ptr just in case there is an exception thrown during // lock acquisition. std::auto_ptr<ScopedDistributedLock> lockHolder(new ScopedDistributedLock( configServer.getConnectionString(), "authorizationData")); lockHolder->setLockMessage(why.toString()); std::string errmsg; if (!lockHolder->acquire(_authzUpdateLockAcquisitionTimeoutMillis, &errmsg)) { warning() << "Error while attempting to acquire distributed lock for user modification: " << errmsg << endl; return false; } _authzDataUpdateLock.reset(lockHolder.release()); return true; }
void AuthzManagerExternalStateMongos::releaseAuthzUpdateLock() { boost::lock_guard<boost::mutex> lkLocal(_distLockGuard); _authzDataUpdateLock.reset(); }