summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorDwight <dwight@10gen.com>2012-03-23 06:22:53 -0400
committerDwight <dwight@10gen.com>2012-03-23 06:22:53 -0400
commitc5aba00d1226eb4267028775b898f26734495092 (patch)
tree3a092b07394b6b23679926d989bab6a93ecee145 /src/mongo
parentda292a8d8eef9c1adc98bcd9e50a3f5eb81bb3ba (diff)
downloadmongo-c5aba00d1226eb4267028775b898f26734495092.tar.gz
we consider admin and local dbs candidates for nested locks. however when writing to admin you need to lock both
in this change we simply W lock the whole system on admin writes. this should make writing to auth work. however there may be better solutions. we may be able to treat admin db as non-nested on writes period.
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/d_concurrency.cpp12
-rw-r--r--src/mongo/db/d_concurrency.h1
2 files changed, 12 insertions, 1 deletions
diff --git a/src/mongo/db/d_concurrency.cpp b/src/mongo/db/d_concurrency.cpp
index e9d8f0cdf6b..049b8948682 100644
--- a/src/mongo/db/d_concurrency.cpp
+++ b/src/mongo/db/d_concurrency.cpp
@@ -618,6 +618,7 @@ namespace mongo {
}
void Lock::DBWrite::lockDB(const string& ns) {
+ locked_W=false;
locked_w=false; weLocked=0; ourCounter = 0;
LockState& ls = lockState();
if( isW(ls) )
@@ -626,6 +627,12 @@ namespace mongo {
char db[MaxDatabaseNameLen];
nsToDatabase(ns.data(), db);
Nestable nested = n(db);
+ if( nested == admin ) {
+ // we can't nestedly lock both admin and local as implemented. so lock_W.
+ lock_W();
+ locked_W = true;
+ return;
+ }
if( !nested )
lock(db);
lockTop(ls);
@@ -689,9 +696,12 @@ namespace mongo {
unlock_W();
}
}
+ if( locked_W ) {
+ unlock_W();
+ }
ourCounter = 0;
weLocked = 0;
- locked_w = false;
+ locked_W = locked_w = false;
}
void Lock::DBRead::unlockDB() {
if( ourCounter ) {
diff --git a/src/mongo/db/d_concurrency.h b/src/mongo/db/d_concurrency.h
index 308f55aeba0..cb3002bd29b 100644
--- a/src/mongo/db/d_concurrency.h
+++ b/src/mongo/db/d_concurrency.h
@@ -83,6 +83,7 @@ namespace mongo {
void lockNestable(Nestable db);
void lock(const string& db);
bool locked_w;
+ bool locked_W;
SimpleRWLock *weLocked;
int *ourCounter;
const string what;