diff options
author | dwight <dwight@10gen.com> | 2012-01-16 21:56:55 -0500 |
---|---|---|
committer | dwight <dwight@10gen.com> | 2012-01-16 21:58:39 -0500 |
commit | e2adb6c54c58c6d63b97650e922fd951c43a2898 (patch) | |
tree | ece507d6c87cf6ddb0bc1d8e2f3a874fee78f75c /src/mongo/db/restapi.cpp | |
parent | 222af62133b202cf97ff555a93695c6693c9e3e2 (diff) | |
download | mongo-e2adb6c54c58c6d63b97650e922fd951c43a2898.tar.gz |
SERVER-2278 recent changes to not do the unlock / relock with write lock if db not opened broke
REST if the db wasn't open - the admin db in particular. fix isn't super elegant because of the timeout stuff
otherwise would have been a one liner
Diffstat (limited to 'src/mongo/db/restapi.cpp')
-rw-r--r-- | src/mongo/db/restapi.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/db/restapi.cpp b/src/mongo/db/restapi.cpp index 370051354a2..f8d3d94ad9b 100644 --- a/src/mongo/db/restapi.cpp +++ b/src/mongo/db/restapi.cpp @@ -235,13 +235,27 @@ namespace mongo { } restHandler; + void openAdminDb() { + { + readlocktryassert rl("admin.system.users", 10000); + if( dbHolder().get("admin.system.users",dbpath) ) + return; + } + + writelocktry wl("admin.", 10000); + assert( wl.got() ); + Client::Context cx( "admin.system.users", dbpath, false ); + } + bool RestAdminAccess::haveAdminUsers() const { + openAdminDb(); readlocktryassert rl("admin.system.users", 10000); Client::Context cx( "admin.system.users", dbpath, false ); return ! Helpers::isEmpty("admin.system.users", false); } BSONObj RestAdminAccess::getAdminUser( const string& username ) const { + openAdminDb(); Client::GodScope gs; readlocktryassert rl("admin.system.users", 10000); Client::Context cx( "admin.system.users" ); |