Add shell helpers db.fsyncLock() and db.fsyncUnlock() and clean up messages SERVER-2789

This commit is contained in:
Mathias Stearn
2011-03-17 18:22:03 -04:00
parent 23d2fb66a1
commit 2775fa3e2b
5 changed files with 31 additions and 10 deletions

View File

@@ -111,7 +111,7 @@ namespace mongo {
unsigned x = lockedForWriting;
if( x ) {
b.append("fsyncLock", x);
b.append("info", "use db.$cmd.sys.unlock.findOne() to terminate the fsync write/snapshot lock");
b.append("info", "use db.fsyncUnlock() to terminate the fsync write/snapshot lock");
}
}
@@ -144,9 +144,12 @@ namespace mongo {
void unlockFsync(const char *ns, Message& m, DbResponse &dbresponse) {
BSONObj obj;
if( ! cc().isAdmin() || strncmp(ns, "admin.", 6) != 0 ) {
if ( ! cc().isAdmin() ) { // checks auth
obj = fromjson("{\"err\":\"unauthorized\"}");
}
else if (strncmp(ns, "admin.", 6) != 0 ) {
obj = fromjson("{\"err\":\"unauthorized - this command must be run against the admin DB\"}");
}
else {
if( lockedForWriting ) {
log() << "command: unlock requested" << endl;