From 3d1f0d67835a0ce4a3213dd0514fe58df3010d56 Mon Sep 17 00:00:00 2001 From: dwight Date: Fri, 15 Apr 2011 16:51:21 -0400 Subject: allow slaveOk on copydb command --- db/cloner.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/cloner.cpp b/db/cloner.cpp index fd86e10b787..74a22659909 100644 --- a/db/cloner.cpp +++ b/db/cloner.cpp @@ -62,6 +62,8 @@ namespace mongo { for example repairDatabase need not use it. */ void setConnection( DBClientWithCommands *c ) { conn.reset( c ); } + + /** copy the entire database */ bool go(const char *masterHost, string& errmsg, const string& fromdb, bool logForRepl, bool slaveOk, bool useReplAuth, bool snapshot, bool mayYield, bool mayBeInterrupted, int *errCode = 0); bool copyCollection( const string& from , const string& ns , const BSONObj& query , string& errmsg , bool mayYield, bool mayBeInterrupted, bool copyIndexes = true, bool logForRepl = true ); @@ -564,9 +566,10 @@ namespace mongo { virtual LockType locktype() const { return WRITE; } virtual void help( stringstream &help ) const { help << "copy a database from another host to this host\n"; - help << "usage: {copydb: 1, fromhost: , fromdb: , todb: [, username: , nonce: , key: ]}"; + help << "usage: {copydb: 1, fromhost: , fromdb: , todb: [, slaveOk: , username: , nonce: , key: ]}"; } virtual bool run(const string& dbname, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) { + bool slaveOk = cmdObj["slaveOk"].trueValue(); string fromhost = cmdObj.getStringField("fromhost"); if ( fromhost.empty() ) { /* copy from self */ @@ -597,7 +600,7 @@ namespace mongo { c.setConnection( authConn_.release() ); } Client::Context ctx(todb); - bool res = c.go(fromhost.c_str(), errmsg, fromdb, /*logForReplication=*/!fromRepl, /*slaveok*/false, /*replauth*/false, /*snapshot*/true, /*mayYield*/true, /*mayBeInterrupted*/ false); + bool res = c.go(fromhost.c_str(), errmsg, fromdb, /*logForReplication=*/!fromRepl, slaveOk, /*replauth*/false, /*snapshot*/true, /*mayYield*/true, /*mayBeInterrupted*/ false); return res; } } cmdcopydb; -- cgit v1.2.1 From feb266b1a9e28cbaa3275fde46679a32af4f6600 Mon Sep 17 00:00:00 2001 From: dwight Date: Fri, 15 Apr 2011 17:32:45 -0400 Subject: fix compile warning --- db/mongommf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/mongommf.cpp b/db/mongommf.cpp index f165baf55b6..70410e9ee2a 100644 --- a/db/mongommf.cpp +++ b/db/mongommf.cpp @@ -101,7 +101,7 @@ namespace mongo { #if 1 // https://jira.mongodb.org/browse/SERVER-2942 DWORD old; - bool ok = VirtualProtect(oldPrivateAddr, len, PAGE_READONLY, &old); + bool ok = VirtualProtect(oldPrivateAddr, (SIZE_T) len, PAGE_READONLY, &old); if( !ok ) { DWORD e = GetLastError(); log() << "VirtualProtect failed in remapPrivateView " << filename() << hex << oldPrivateAddr << ' ' << len << ' ' << errnoWithDescription(e) << endl; -- cgit v1.2.1 From 17892972aa45c2abdd15c353c37ae4ebdb5daf1e Mon Sep 17 00:00:00 2001 From: dwight Date: Fri, 15 Apr 2011 17:42:22 -0400 Subject: should be endl --- db/pdfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/pdfile.cpp b/db/pdfile.cpp index 2533ebb5798..8828a8853e7 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -2051,7 +2051,7 @@ namespace mongo { bool ok = false; BOOST_CHECK_EXCEPTION( ok = fo.apply( q ) ); if ( ok ) - log(2) << fo.op() << " file " << q.string() << '\n'; + log(2) << fo.op() << " file " << q.string() << endl; int i = 0; int extra = 10; // should not be necessary, this is defensive in case there are missing files while ( 1 ) { -- cgit v1.2.1