diff options
Diffstat (limited to 'src/mongo/client')
24 files changed, 155 insertions, 155 deletions
diff --git a/src/mongo/client/clientAndShell.cpp b/src/mongo/client/clientAndShell.cpp index 401c8c9eb63..02a603c4e82 100644 --- a/src/mongo/client/clientAndShell.cpp +++ b/src/mongo/client/clientAndShell.cpp @@ -75,16 +75,16 @@ namespace mongo { } void Shard::getAllShards( vector<Shard>& all ) { - assert(0); + verify(0); } bool Shard::isAShardNode( const string& ident ) { - assert(0); + verify(0); return false; } string prettyHostName() { - assert(0); + verify(0); return ""; } diff --git a/src/mongo/client/clientOnly.cpp b/src/mongo/client/clientOnly.cpp index 767e97ce878..e44de42a446 100644 --- a/src/mongo/client/clientOnly.cpp +++ b/src/mongo/client/clientOnly.cpp @@ -22,7 +22,7 @@ namespace mongo { string dynHostMyName() { return ""; } void dynHostResolve(string& name, int& port) { - assert(false); + verify(false); } } diff --git a/src/mongo/client/connpool.cpp b/src/mongo/client/connpool.cpp index 89f804fd177..41ff1c0aa2d 100644 --- a/src/mongo/client/connpool.cpp +++ b/src/mongo/client/connpool.cpp @@ -60,7 +60,7 @@ namespace mongo { continue; } - assert( sc.conn->getSoTimeout() == socketTimeout ); + verify( sc.conn->getSoTimeout() == socketTimeout ); return sc.conn; @@ -133,7 +133,7 @@ namespace mongo { } DBClientBase* DBConnectionPool::_get(const string& ident , double socketTimeout ) { - assert( ! inShutdown() ); + verify( ! inShutdown() ); scoped_lock L(_mutex); PoolForHost& p = _pools[PoolKey(ident,socketTimeout)]; return p.get( this , socketTimeout ); @@ -347,7 +347,7 @@ namespace mongo { ++ap; ++bp; } - assert(false); + verify(false); } bool DBConnectionPool::poolKeyCompare::operator()( const PoolKey& a , const PoolKey& b ) const { @@ -387,7 +387,7 @@ namespace mongo { // ------ ScopedDbConnection ------ ScopedDbConnection * ScopedDbConnection::steal() { - assert( _conn ); + verify( _conn ); ScopedDbConnection * n = new ScopedDbConnection( _host , _conn, _socketTimeout ); _conn = 0; return n; diff --git a/src/mongo/client/connpool.h b/src/mongo/client/connpool.h index 8733abb1f90..2c7618bc630 100644 --- a/src/mongo/client/connpool.h +++ b/src/mongo/client/connpool.h @@ -38,9 +38,9 @@ namespace mongo { : _created(0) {} PoolForHost( const PoolForHost& other ) { - assert(other._pool.size() == 0); + verify(other._pool.size() == 0); _created = other._created; - assert( _created == 0 ); + verify( _created == 0 ); } ~PoolForHost(); @@ -50,7 +50,7 @@ namespace mongo { void createdOne( DBClientBase * base ); long long numCreated() const { return _created; } - ConnectionString::ConnectionType type() const { assert(_created); return _type; } + ConnectionString::ConnectionType type() const { verify(_created); return _type; } /** * gets a connection or return NULL diff --git a/src/mongo/client/dbclient.cpp b/src/mongo/client/dbclient.cpp index fc1ace395e3..3c5544f5658 100644 --- a/src/mongo/client/dbclient.cpp +++ b/src/mongo/client/dbclient.cpp @@ -111,7 +111,7 @@ namespace mongo { break; } - assert( 0 ); + verify( 0 ); return 0; } @@ -151,7 +151,7 @@ namespace mongo { case SYNC: return "sync"; } - assert(0); + verify(0); return ""; } @@ -164,7 +164,7 @@ namespace mongo { Query& Query::where(const string &jscode, BSONObj scope) { /* use where() before sort() and hint() and explain(), else this will assert. */ - assert( ! isComplex() ); + verify( ! isComplex() ); BSONObjBuilder b; b.appendElements(obj); b.appendWhere(jscode, scope); @@ -395,7 +395,7 @@ namespace mongo { } { BSONElement e = info.getField("nonce"); - assert( e.type() == String ); + verify( e.type() == String ); nonce = e.valuestr(); } @@ -443,7 +443,7 @@ namespace mongo { } bool DBClientWithCommands::createCollection(const string &ns, long long size, bool capped, int max, BSONObj *info) { - assert(!capped||size); + verify(!capped||size); BSONObj o; if ( info == 0 ) info = &o; BSONObjBuilder b; @@ -1068,7 +1068,7 @@ namespace mongo { *host = _serverString; if ( clientSet && nReturned ) { - assert(data); + verify(data); BSONObj o(data); if ( isNotMasterErrorString( getErrField(o) ) ) { clientSet->isntMaster(); diff --git a/src/mongo/client/dbclient_rs.cpp b/src/mongo/client/dbclient_rs.cpp index 50028c28243..c2de3f1614d 100644 --- a/src/mongo/client/dbclient_rs.cpp +++ b/src/mongo/client/dbclient_rs.cpp @@ -248,7 +248,7 @@ namespace mongo { bool wasMaster = false; // This is always true, since checked in port() - assert( prev.port() >= 0 ); + verify( prev.port() >= 0 ); if( prev.host().size() ){ scoped_lock lk( _lock ); for ( unsigned i=0; i<_nodes.size(); i++ ) { @@ -292,7 +292,7 @@ namespace mongo { uassert(15899, str::stream() << "No suitable member found for slaveOk query in replica set: " << _name, _master >= 0 && _nodes[_master].ok); // Fall back to primary - assert( static_cast<unsigned>(_master) < _nodes.size() ); + verify( static_cast<unsigned>(_master) < _nodes.size() ); LOG(2) << "dbclient_rs getSlave no member in secondary state found, returning primary " << _nodes[ _master ] << endl; return _nodes[_master].addr; } @@ -433,7 +433,7 @@ namespace mongo { set<string> added = diff.first; set<int> removed = diff.second; - assert( added.size() > 0 || removed.size() > 0 ); + verify( added.size() > 0 || removed.size() > 0 ); changed = true; // Delete from the end so we don't invalidate as we delete, delete indices are ascending @@ -472,7 +472,7 @@ namespace mongo { bool ReplicaSetMonitor::_checkConnection( DBClientConnection * c , string& maybePrimary , bool verbose , int nodesOffset ) { - assert( c ); + verify( c ); scoped_lock lk( _checkConnectionLock ); bool isMaster = false; bool changed = false; @@ -800,7 +800,7 @@ namespace mongo { // since we don't know which server it belongs to // can't assume master because of slave ok // and can have a cursor survive a master change - assert(0); + verify(0); } void DBClientReplicaSet::isntMaster() { @@ -882,7 +882,7 @@ namespace mongo { bool DBClientReplicaSet::recv( Message& m ) { - assert( _lazyState._lastClient ); + verify( _lazyState._lastClient ); // TODO: It would be nice if we could easily wrap a conn error as a result error try { @@ -939,7 +939,7 @@ namespace mongo { } else{ (void)wasMaster; // silence set-but-not-used warning - // assert( wasMaster ); + // verify( wasMaster ); // printStackTrace(); log() << "too many retries (" << _lazyState._retries << "), could not get data from replica set" << endl; } diff --git a/src/mongo/client/dbclientcursor.cpp b/src/mongo/client/dbclientcursor.cpp index bfd4108f6ea..ab80830adf3 100644 --- a/src/mongo/client/dbclientcursor.cpp +++ b/src/mongo/client/dbclientcursor.cpp @@ -62,7 +62,7 @@ namespace mongo { bool DBClientCursor::init() { Message toSend; _assembleInit( toSend ); - assert( _client ); + verify( _client ); if ( !_client->call( toSend, *batch.m, false, &_originalHost ) ) { // log msg temp? log() << "DBClientCursor::init call() failed" << endl; @@ -107,11 +107,11 @@ namespace mongo { } void DBClientCursor::requestMore() { - assert( cursorId && batch.pos == batch.nReturned ); + verify( cursorId && batch.pos == batch.nReturned ); if (haveLimit) { nToReturn -= batch.nReturned; - assert(nToReturn > 0); + verify(nToReturn > 0); } BufBuilder b; b.appendNum(opts); @@ -129,7 +129,7 @@ namespace mongo { dataReceived(); } else { - assert( _scopedHost.size() ); + verify( _scopedHost.size() ); ScopedDbConnection conn( _scopedHost ); conn->call( toSend , *response ); _client = conn.get(); @@ -142,10 +142,10 @@ namespace mongo { /** with QueryOption_Exhaust, the server just blasts data at us (marked at end with cursorid==0). */ void DBClientCursor::exhaustReceiveMore() { - assert( cursorId && batch.pos == batch.nReturned ); - assert( !haveLimit ); + verify( cursorId && batch.pos == batch.nReturned ); + verify( !haveLimit ); auto_ptr<Message> response(new Message()); - assert( _client ); + verify( _client ); if ( _client->recv(*response) ) { batch.m = response; dataReceived(); @@ -163,7 +163,7 @@ namespace mongo { if ( qr->resultFlags() & ResultFlag_CursorNotFound ) { // cursor id no longer valid at the server. - assert( qr->cursorId == 0 ); + verify( qr->cursorId == 0 ); cursorId = 0; // 0 indicates no longer valid (dead) if ( ! ( opts & QueryOption_CursorTailable ) ) throw UserException( 13127 , "getMore: cursor didn't exist on server, possible restart or timeout?" ); @@ -183,12 +183,12 @@ namespace mongo { if( qr->resultFlags() & ResultFlag_ShardConfigStale ) { BSONObj error; - assert( peekError( &error ) ); + verify( peekError( &error ) ); throw RecvStaleConfigException( (string)"stale config on lazy receive" + causedBy( getErrField( error ) ), error ); } /* this assert would fire the way we currently work: - assert( nReturned || cursorId == 0 ); + verify( nReturned || cursorId == 0 ); */ } @@ -267,17 +267,17 @@ namespace mongo { vector<BSONObj> v; peek(v, 1); - assert( v.size() == 1 ); - assert( hasErrField( v[0] ) ); + verify( v.size() == 1 ); + verify( hasErrField( v[0] ) ); if( error ) *error = v[0].getOwned(); return true; } void DBClientCursor::attach( AScopedConnection * conn ) { - assert( _scopedHost.size() == 0 ); - assert( conn ); - assert( conn->get() ); + verify( _scopedHost.size() == 0 ); + verify( conn ); + verify( conn->get() ); if ( conn->get()->type() == ConnectionString::SET || conn->get()->type() == ConnectionString::SYNC ) { @@ -322,7 +322,7 @@ namespace mongo { } else { - assert( _scopedHost.size() ); + verify( _scopedHost.size() ); ScopedDbConnection conn( _scopedHost ); if( DBClientConnection::getLazyKillCursor() ) diff --git a/src/mongo/client/dbclientinterface.h b/src/mongo/client/dbclientinterface.h index a979581b4a9..6f05424b348 100644 --- a/src/mongo/client/dbclientinterface.h +++ b/src/mongo/client/dbclientinterface.h @@ -150,17 +150,17 @@ namespace mongo { switch ( _type ) { case MASTER: - assert( _servers.size() == 1 ); + verify( _servers.size() == 1 ); break; case SET: - assert( _setName.size() ); - assert( _servers.size() >= 1 ); // 1 is ok since we can derive + verify( _setName.size() ); + verify( _servers.size() >= 1 ); // 1 is ok since we can derive break; case PAIR: - assert( _servers.size() == 2 ); + verify( _servers.size() == 2 ); break; default: - assert( _servers.size() > 0 ); + verify( _servers.size() > 0 ); } _finishInit(); @@ -178,7 +178,7 @@ namespace mongo { } else { _type = favoredMultipleType; - assert( _type == SET || _type == SYNC ); + verify( _type == SET || _type == SYNC ); } _finishInit(); } @@ -408,7 +408,7 @@ namespace mongo { virtual void say( Message &toSend, bool isRetry = false , string * actualServer = 0 ) = 0; virtual void sayPiggyBack( Message &toSend ) = 0; /* used by QueryOption_Exhaust. To use that your subclass must implement this. */ - virtual bool recv( Message& m ) { assert(false); return false; } + virtual bool recv( Message& m ) { verify(false); return false; } // In general, for lazy queries, we'll need to say, recv, then checkResponse virtual void checkResponse( const char* data, int nReturned, bool* retry = NULL, string* targetHost = NULL ) { if( retry ) *retry = false; if( targetHost ) *targetHost = ""; @@ -977,7 +977,7 @@ namespace mongo { */ bool isFailed() const { return _failed; } - MessagingPort& port() { assert(p); return *p; } + MessagingPort& port() { verify(p); return *p; } string toStringLong() const { stringstream ss; diff --git a/src/mongo/client/distlock.cpp b/src/mongo/client/distlock.cpp index aa8936d5ce8..9310e8ad3b0 100644 --- a/src/mongo/client/distlock.cpp +++ b/src/mongo/client/distlock.cpp @@ -55,7 +55,7 @@ namespace mongo { string getDistLockProcess() { if (!_cachedProcessString) initModule(); - assert( _cachedProcessString ); + verify( _cachedProcessString ); return *_cachedProcessString; } @@ -275,7 +275,7 @@ namespace mongo { string pingId = pingThreadId( conn, processId ); - assert( _seen.count( pingId ) > 0 ); + verify( _seen.count( pingId ) > 0 ); _kill.insert( pingId ); } @@ -483,7 +483,7 @@ namespace mongo { } // This should always be true, if not, we are using the lock incorrectly. - assert( _name != "" ); + verify( _name != "" ); // write to dummy if 'other' is null BSONObj dummyOther; @@ -638,7 +638,7 @@ namespace mongo { } else { - assert( canReenter ); + verify( canReenter ); // Lock may be re-entered, reset our timer if succeeds or fails // Not strictly necessary, but helpful for small timeouts where thread scheduling is significant. @@ -776,7 +776,7 @@ namespace mongo { // Our lock should now be set until forcing. // It's possible another lock has won entirely by now, so state could be 1 or 2 here - assert( indUpdate["state"].numberInt() > 0 ); + verify( indUpdate["state"].numberInt() > 0 ); } // else our lock is the same, in which case we're safe, or it's a bigger lock, @@ -790,7 +790,7 @@ namespace mongo { << up[1].first << causedBy( e ), 13661 ); } - assert( !indUpdate.isEmpty() ); + verify( !indUpdate.isEmpty() ); // Find max TS value if ( currLock.isEmpty() || currLock["ts"] < indUpdate["ts"] ) { @@ -891,7 +891,7 @@ namespace mongo { // and so cannot tell you what lock ts you should try later. void DistributedLock::unlock( BSONObj* oldLockPtr ) { - assert( _name != "" ); + verify( _name != "" ); string lockName = _name + string("/") + _processId; diff --git a/src/mongo/client/distlock.h b/src/mongo/client/distlock.h index 44b54560fb4..f8b55cc66f8 100644 --- a/src/mongo/client/distlock.h +++ b/src/mongo/client/distlock.h @@ -227,7 +227,7 @@ namespace mongo { ~dist_lock_try() { if ( _got ) { - assert( ! _other.isEmpty() ); + verify( ! _other.isEmpty() ); _lock->unlock( &_other ); } } @@ -237,9 +237,9 @@ namespace mongo { } bool retry() { - assert( _lock ); - assert( _got ); - assert( ! _other.isEmpty() ); + verify( _lock ); + verify( _got ); + verify( ! _other.isEmpty() ); return _got = _lock->lock_try( _why , true, &_other ); } diff --git a/src/mongo/client/distlock_test.cpp b/src/mongo/client/distlock_test.cpp index a46caa44c11..9f78bbbb2c3 100644 --- a/src/mongo/client/distlock_test.cpp +++ b/src/mongo/client/distlock_test.cpp @@ -264,7 +264,7 @@ namespace mongo { } else { log() << "**** Not unlocking for thread " << threadId << endl; - assert( DistributedLock::killPinger( *myLock ) ); + verify( DistributedLock::killPinger( *myLock ) ); // We're simulating a crashed process... break; } diff --git a/src/mongo/client/examples/authTest.cpp b/src/mongo/client/examples/authTest.cpp index 71cdd390cff..05a6de45b16 100644 --- a/src/mongo/client/examples/authTest.cpp +++ b/src/mongo/client/examples/authTest.cpp @@ -48,7 +48,7 @@ int main( int argc, const char **argv ) { bool ok = conn.auth( "test" , "eliot" , "bar" , errmsg ); if ( ! ok ) cout << errmsg << endl; - MONGO_assert( ok ); + MONGO_verify( ok ); - MONGO_assert( ! conn.auth( "test" , "eliot" , "bars" , errmsg ) ); + MONGO_verify( ! conn.auth( "test" , "eliot" , "bars" , errmsg ) ); } diff --git a/src/mongo/client/examples/clientTest.cpp b/src/mongo/client/examples/clientTest.cpp index aaea6bd1bdf..11acac88ae8 100644 --- a/src/mongo/client/examples/clientTest.cpp +++ b/src/mongo/client/examples/clientTest.cpp @@ -24,8 +24,8 @@ #include <iostream> -#ifndef assert -# define assert(x) MONGO_assert(x) +#ifndef verify +# define verify(x) MONGO_verify(x) #endif using namespace std; @@ -53,24 +53,24 @@ int main( int argc, const char **argv ) { // clean up old data from any previous tests conn.remove( ns, BSONObj() ); - assert( conn.findOne( ns , BSONObj() ).isEmpty() ); + verify( conn.findOne( ns , BSONObj() ).isEmpty() ); // test insert conn.insert( ns ,BSON( "name" << "eliot" << "num" << 1 ) ); - assert( ! conn.findOne( ns , BSONObj() ).isEmpty() ); + verify( ! conn.findOne( ns , BSONObj() ).isEmpty() ); // test remove conn.remove( ns, BSONObj() ); - assert( conn.findOne( ns , BSONObj() ).isEmpty() ); + verify( conn.findOne( ns , BSONObj() ).isEmpty() ); // insert, findOne testing conn.insert( ns , BSON( "name" << "eliot" << "num" << 1 ) ); { BSONObj res = conn.findOne( ns , BSONObj() ); - assert( strstr( res.getStringField( "name" ) , "eliot" ) ); - assert( ! strstr( res.getStringField( "name2" ) , "eliot" ) ); - assert( 1 == res.getIntField( "num" ) ); + verify( strstr( res.getStringField( "name" ) , "eliot" ) ); + verify( ! strstr( res.getStringField( "name2" ) , "eliot" ) ); + verify( 1 == res.getIntField( "num" ) ); } @@ -83,7 +83,7 @@ int main( int argc, const char **argv ) { count++; BSONObj obj = cursor->next(); } - assert( count == 2 ); + verify( count == 2 ); } { @@ -93,7 +93,7 @@ int main( int argc, const char **argv ) { count++; BSONObj obj = cursor->next(); } - assert( count == 1 ); + verify( count == 1 ); } { @@ -103,45 +103,45 @@ int main( int argc, const char **argv ) { count++; BSONObj obj = cursor->next(); } - assert( count == 0 ); + verify( count == 0 ); } // update { BSONObj res = conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot" ).obj() ); - assert( ! strstr( res.getStringField( "name2" ) , "eliot" ) ); + verify( ! strstr( res.getStringField( "name2" ) , "eliot" ) ); BSONObj after = BSONObjBuilder().appendElements( res ).append( "name2" , "h" ).obj(); conn.update( ns , BSONObjBuilder().append( "name" , "eliot2" ).obj() , after ); res = conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot" ).obj() ); - assert( ! strstr( res.getStringField( "name2" ) , "eliot" ) ); - assert( conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot2" ).obj() ).isEmpty() ); + verify( ! strstr( res.getStringField( "name2" ) , "eliot" ) ); + verify( conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot2" ).obj() ).isEmpty() ); conn.update( ns , BSONObjBuilder().append( "name" , "eliot" ).obj() , after ); res = conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot" ).obj() ); - assert( strstr( res.getStringField( "name" ) , "eliot" ) ); - assert( strstr( res.getStringField( "name2" ) , "h" ) ); - assert( conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot2" ).obj() ).isEmpty() ); + verify( strstr( res.getStringField( "name" ) , "eliot" ) ); + verify( strstr( res.getStringField( "name2" ) , "h" ) ); + verify( conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot2" ).obj() ).isEmpty() ); // upsert conn.update( ns , BSONObjBuilder().append( "name" , "eliot2" ).obj() , after , 1 ); - assert( ! conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot" ).obj() ).isEmpty() ); + verify( ! conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot" ).obj() ).isEmpty() ); } { // ensure index - assert( conn.ensureIndex( ns , BSON( "name" << 1 ) ) ); - assert( ! conn.ensureIndex( ns , BSON( "name" << 1 ) ) ); + verify( conn.ensureIndex( ns , BSON( "name" << 1 ) ) ); + verify( ! conn.ensureIndex( ns , BSON( "name" << 1 ) ) ); } { // hint related tests - assert( conn.findOne(ns, "{}")["name"].str() == "sara" ); + verify( conn.findOne(ns, "{}")["name"].str() == "sara" ); - assert( conn.findOne(ns, "{ name : 'eliot' }")["name"].str() == "eliot" ); - assert( conn.getLastError() == "" ); + verify( conn.findOne(ns, "{ name : 'eliot' }")["name"].str() == "eliot" ); + verify( conn.getLastError() == "" ); // nonexistent index test bool asserted = false; @@ -151,13 +151,13 @@ int main( int argc, const char **argv ) { catch ( ... ) { asserted = true; } - assert( asserted ); + verify( asserted ); //existing index - assert( conn.findOne(ns, Query("{name:'eliot'}").hint("{name:1}")).hasElement("name") ); + verify( conn.findOne(ns, Query("{name:'eliot'}").hint("{name:1}")).hasElement("name") ); // run validate - assert( conn.validate( ns ) ); + verify( conn.validate( ns ) ); } { @@ -189,14 +189,14 @@ int main( int argc, const char **argv ) { BSONObj found = conn.findOne( tsns , mongo::BSONObj() ); cout << "old: " << out << "\nnew: " << found << endl; - assert( ( oldTime < found["ts"].timestampTime() ) || + verify( ( oldTime < found["ts"].timestampTime() ) || ( oldTime == found["ts"].timestampTime() && oldInc < found["ts"].timestampInc() ) ); } { // check that killcursors doesn't affect last error - assert( conn.getLastError().empty() ); + verify( conn.getLastError().empty() ); BufBuilder b; b.appendNum( (int)0 ); // reserved @@ -209,7 +209,7 @@ int main( int argc, const char **argv ) { // say() is protected in DBClientConnection, so get superclass static_cast< DBConnector* >( &conn )->say( m ); - assert( conn.getLastError().empty() ); + verify( conn.getLastError().empty() ); } { @@ -258,7 +258,7 @@ int main( int argc, const char **argv ) { BSONObj res; bool gotError = false; - assert( conn.eval( "test" , "return db.totest.findOne().x" , res ) ); + verify( conn.eval( "test" , "return db.totest.findOne().x" , res ) ); try { conn.eval( "test" , "sleep(5000); return db.totest.findOne().x" , res ); } @@ -266,11 +266,11 @@ int main( int argc, const char **argv ) { gotError = true; log() << e.what() << endl; } - assert( gotError ); + verify( gotError ); // sleep so the server isn't locked anymore sleepsecs( 4 ); - assert( conn.eval( "test" , "return db.totest.findOne().x" , res ) ); + verify( conn.eval( "test" , "return db.totest.findOne().x" , res ) ); } diff --git a/src/mongo/client/examples/httpClientTest.cpp b/src/mongo/client/examples/httpClientTest.cpp index 4055d4492d5..f5f89ac413f 100644 --- a/src/mongo/client/examples/httpClientTest.cpp +++ b/src/mongo/client/examples/httpClientTest.cpp @@ -27,10 +27,10 @@ void play( string url ) { HttpClient c; HttpClient::Result r; - MONGO_assert( c.get( url , &r ) == 200 ); + MONGO_verify( c.get( url , &r ) == 200 ); HttpClient::Headers h = r.getHeaders(); - MONGO_assert( h["Content-Type"].find( "text/html" ) == 0 ); + MONGO_verify( h["Content-Type"].find( "text/html" ) == 0 ); cout << "\tHeaders" << endl; for ( HttpClient::Headers::iterator i = h.begin() ; i != h.end(); ++i ) { diff --git a/src/mongo/client/examples/mongoperf.cpp b/src/mongo/client/examples/mongoperf.cpp index f89f769d0cf..9658f9406c0 100644 --- a/src/mongo/client/examples/mongoperf.cpp +++ b/src/mongo/client/examples/mongoperf.cpp @@ -100,7 +100,7 @@ void workerThread() { } void go() { - assert( options["r"].trueValue() || options["w"].trueValue() ); + verify( options["r"].trueValue() || options["w"].trueValue() ); MemoryMappedFile f; cout << "creating test file size:"; len = options["fileSizeMB"].numberLong(); @@ -138,7 +138,7 @@ void go() { lf = 0; mmfFile = new MemoryMappedFile(); mmf = (char *) mmfFile->map(fname); - assert( mmf ); + verify( mmf ); syncDelaySecs = options["syncDelay"].numberInt(); if( syncDelaySecs ) { diff --git a/src/mongo/client/examples/whereExample.cpp b/src/mongo/client/examples/whereExample.cpp index 12b68d7add3..413ea26137a 100644 --- a/src/mongo/client/examples/whereExample.cpp +++ b/src/mongo/client/examples/whereExample.cpp @@ -65,5 +65,5 @@ int main( int argc, const char **argv ) { cout << "\t" << obj.jsonString() << endl; num++; } - MONGO_assert( num == 1 ); + MONGO_verify( num == 1 ); } diff --git a/src/mongo/client/gridfs.cpp b/src/mongo/client/gridfs.cpp index 7024516e9a6..056502d8888 100644 --- a/src/mongo/client/gridfs.cpp +++ b/src/mongo/client/gridfs.cpp @@ -117,7 +117,7 @@ namespace mongo { chunkLen += readLen; bufPos += readLen; - assert(chunkLen <= _chunkSize); + verify(chunkLen <= _chunkSize); } GridFSChunk c(idObj, chunkNumber, buf, chunkLen); diff --git a/src/mongo/client/model.cpp b/src/mongo/client/model.cpp index bd10a3c5528..3cb77822efc 100644 --- a/src/mongo/client/model.cpp +++ b/src/mongo/client/model.cpp @@ -99,7 +99,7 @@ namespace mongo { b.append( myId ); } - assert( ! myId.eoo() ); + verify( ! myId.eoo() ); BSONObjBuilder qb; qb.append( myId ); diff --git a/src/mongo/client/parallel.cpp b/src/mongo/client/parallel.cpp index 91ee6f6d624..eab7d6c3be9 100644 --- a/src/mongo/client/parallel.cpp +++ b/src/mongo/client/parallel.cpp @@ -83,7 +83,7 @@ namespace mongo { } void ClusteredCursor::_checkCursor( DBClientCursor * cursor ) { - assert( cursor ); + verify( cursor ); if ( cursor->hasResultFlag( ResultFlag_ShardConfigStale ) ) { BSONObj error; @@ -99,7 +99,7 @@ namespace mongo { auto_ptr<DBClientCursor> ClusteredCursor::query( const string& server , int num , BSONObj extra , int skipLeft , bool lazy ) { uassert( 10017 , "cursor already done" , ! _done ); - assert( _didInit ); + verify( _didInit ); BSONObj q = _query; if ( ! extra.isEmpty() ) { @@ -131,7 +131,7 @@ namespace mongo { massert( 13633 , str::stream() << "error querying server: " << server , cursor.get() ); cursor->attach( &conn ); // this calls done on conn - assert( ! conn.ok() ); + verify( ! conn.ok() ); _checkCursor( cursor.get() ); return cursor; } @@ -205,9 +205,9 @@ namespace mongo { if( ( isVersioned() && ! isSharded() ) || _qShards.size() == 1 ){ map<string,list<BSONObj> > out; _explain( out ); - assert( out.size() == 1 ); + verify( out.size() == 1 ); list<BSONObj>& l = out.begin()->second; - assert( l.size() == 1 ); + verify( l.size() == 1 ); b.appendElements( *(l.begin()) ); return; } @@ -338,8 +338,8 @@ namespace mongo { } BSONObj FilteringClientCursor::next() { - assert( ! _next.isEmpty() ); - assert( ! _done ); + verify( ! _next.isEmpty() ); + verify( ! _done ); BSONObj ret = _next; _next = BSONObj(); @@ -354,7 +354,7 @@ namespace mongo { } void FilteringClientCursor::_advance() { - assert( _next.isEmpty() ); + verify( _next.isEmpty() ); if ( ! _cursor.get() || _done ) return; @@ -469,7 +469,7 @@ namespace mongo { _sortKey = _qSpec.sort(); _fields = _qSpec.fields(); - if( ! isVersioned() ) assert( _cInfo.isEmpty() ); + if( ! isVersioned() ) verify( _cInfo.isEmpty() ); } if ( ! _sortKey.isEmpty() && ! _fields.isEmpty() ) { @@ -532,8 +532,8 @@ namespace mongo { } else if( initialized ){ - assert( pcState->cursor ); - assert( pcState->conn ); + verify( pcState->cursor ); + verify( pcState->conn ); if( ! finished && pcState->conn->ok() ){ try{ @@ -557,7 +557,7 @@ namespace mongo { pcState.reset(); } - else assert( finished || ! initialized ); + else verify( finished || ! initialized ); initialized = false; finished = false; @@ -729,7 +729,7 @@ namespace mongo { } - assert( todo.size() ); + verify( todo.size() ); log( pc ) << "initializing over " << todo.size() << " shards required by " << vinfo << endl; @@ -749,7 +749,7 @@ namespace mongo { if( mdata.initialized ){ - assert( mdata.pcState ); + verify( mdata.pcState ); PCStatePtr state = mdata.pcState; @@ -794,7 +794,7 @@ namespace mongo { if( manager ) state->manager = manager; else if( primary ) state->primary = primary; - assert( ! primary || shard == *primary || ! isVersioned() ); + verify( ! primary || shard == *primary || ! isVersioned() ); // Setup conn if( ! state->conn ) state->conn.reset( new ShardConnection( shard, ns, manager ) ); @@ -927,17 +927,17 @@ namespace mongo { if( ! mdata.pcState ) continue; // Make sure all state is in shards - assert( todo.find( shard ) != todo.end() ); - assert( mdata.initialized = true ); - if( ! mdata.completed ) assert( mdata.pcState->conn->ok() ); - assert( mdata.pcState->cursor ); - if( isVersioned() ) assert( mdata.pcState->primary || mdata.pcState->manager ); - else assert( ! mdata.pcState->primary || ! mdata.pcState->manager ); - assert( ! mdata.retryNext ); - - if( mdata.completed ) assert( mdata.finished ); - if( mdata.finished ) assert( mdata.initialized ); - if( ! returnPartial ) assert( mdata.initialized ); + verify( todo.find( shard ) != todo.end() ); + verify( mdata.initialized = true ); + if( ! mdata.completed ) verify( mdata.pcState->conn->ok() ); + verify( mdata.pcState->cursor ); + if( isVersioned() ) verify( mdata.pcState->primary || mdata.pcState->manager ); + else verify( ! mdata.pcState->primary || ! mdata.pcState->manager ); + verify( ! mdata.retryNext ); + + if( mdata.completed ) verify( mdata.finished ); + if( mdata.finished ) verify( mdata.initialized ); + if( ! returnPartial ) verify( mdata.initialized ); } } @@ -968,13 +968,13 @@ namespace mongo { try { // Sanity checks - if( ! mdata.completed ) assert( state->conn && state->conn->ok() ); - assert( state->cursor ); + if( ! mdata.completed ) verify( state->conn && state->conn->ok() ); + verify( state->cursor ); if( isVersioned() ){ - assert( state->manager || state->primary ); - assert( ! state->manager || ! state->primary ); + verify( state->manager || state->primary ); + verify( ! state->manager || ! state->primary ); } - else assert( ! state->manager && ! state->primary ); + else verify( ! state->manager && ! state->primary ); // If we weren't init'ing lazily, ignore this @@ -1095,13 +1095,13 @@ namespace mongo { else ++i; // Make sure all state is in shards - assert( mdata.initialized = true ); - assert( mdata.finished = true ); - assert( mdata.completed = true ); - assert( ! mdata.pcState->conn->ok() ); - assert( mdata.pcState->cursor ); - if( isVersioned() ) assert( mdata.pcState->primary || mdata.pcState->manager ); - else assert( ! mdata.pcState->primary && ! mdata.pcState->manager ); + verify( mdata.initialized = true ); + verify( mdata.finished = true ); + verify( mdata.completed = true ); + verify( ! mdata.pcState->conn->ok() ); + verify( mdata.pcState->cursor ); + if( isVersioned() ) verify( mdata.pcState->primary || mdata.pcState->manager ); + else verify( ! mdata.pcState->primary && ! mdata.pcState->manager ); } // TODO : More cleanup of metadata? @@ -1179,7 +1179,7 @@ namespace mongo { // log() << "Starting parallel search..." << endl; // make sure we're not already initialized - assert( ! _cursors ); + verify( ! _cursors ); _cursors = new FilteringClientCursor[_numServers]; bool returnPartial = ( _options & QueryOption_PartialResults ); @@ -1302,7 +1302,7 @@ namespace mongo { continue; } - assert( conns[i] ); + verify( conns[i] ); retryQueries.erase( i ); bool retry = false; @@ -1374,7 +1374,7 @@ namespace mongo { } // Don't exceed our max retries, should not happen - assert( retries < 5 ); + verify( retries < 5 ); } while( retryQueries.size() > 0 /* something to retry */ && ( socketExs.size() == 0 || returnPartial ) /* no conn issues */ && @@ -1383,7 +1383,7 @@ namespace mongo { // Assert that our conns are all closed! for( vector< shared_ptr<ShardConnection> >::iterator i = conns.begin(); i < conns.end(); ++i ){ - assert( ! (*i) || ! (*i)->ok() ); + verify( ! (*i) || ! (*i)->ok() ); } // Handle errors we got during initialization. @@ -1560,7 +1560,7 @@ namespace mongo { } catch ( RecvStaleConfigException& e ){ - assert( versionManager.isVersionableCB( _conn ) ); + verify( versionManager.isVersionableCB( _conn ) ); if( i >= maxRetries ){ error() << "Future::spawnComand (part 2) stale config exception" << causedBy( e ) << endl; @@ -1578,7 +1578,7 @@ namespace mongo { LOG( i > 1 ? 0 : 1 ) << "retrying lazy command" << causedBy( e ) << endl; - assert( _conn->lazySupported() ); + verify( _conn->lazySupported() ); _done = false; init(); continue; diff --git a/src/mongo/client/parallel.h b/src/mongo/client/parallel.h index b48330b6ac6..c566d92c046 100644 --- a/src/mongo/client/parallel.h +++ b/src/mongo/client/parallel.h @@ -417,12 +417,12 @@ namespace mongo { bool isDone() const { return _done; } bool ok() const { - assert( _done ); + verify( _done ); return _ok; } BSONObj result() const { - assert( _done ); + verify( _done ); return _res; } diff --git a/src/mongo/client/redef_macros.h b/src/mongo/client/redef_macros.h index 1a492dc03b0..78bb98a37d2 100644 --- a/src/mongo/client/redef_macros.h +++ b/src/mongo/client/redef_macros.h @@ -29,7 +29,7 @@ #define realloc MONGO_realloc // util/assert_util.h -#define assert MONGO_assert +#define verify MONGO_verify #define dassert MONGO_dassert #define wassert MONGO_wassert #define massert MONGO_massert diff --git a/src/mongo/client/syncclusterconnection.cpp b/src/mongo/client/syncclusterconnection.cpp index 13505495e9f..6f500f4728e 100644 --- a/src/mongo/client/syncclusterconnection.cpp +++ b/src/mongo/client/syncclusterconnection.cpp @@ -62,7 +62,7 @@ namespace mongo { } SyncClusterConnection::SyncClusterConnection( SyncClusterConnection& prev, double socketTimeout) : _mutex("SyncClusterConnection"), _socketTimeout( socketTimeout ) { - assert(0); + verify(0); } SyncClusterConnection::~SyncClusterConnection() { @@ -120,7 +120,7 @@ namespace mongo { errors.push_back( err ); } - assert( _lastErrors.size() == errors.size() && _lastErrors.size() == _conns.size() ); + verify( _lastErrors.size() == errors.size() && _lastErrors.size() == _conns.size() ); stringstream err; bool ok = true; @@ -313,7 +313,7 @@ namespace mongo { if ( _writeConcern ) { _checkLast(); - assert( _lastErrors.size() > 1 ); + verify( _lastErrors.size() > 1 ); int a = _lastErrors[0]["n"].numberInt(); for ( unsigned i=1; i<_lastErrors.size(); i++ ) { @@ -379,7 +379,7 @@ namespace mongo { } void SyncClusterConnection::sayPiggyBack( Message &toSend ) { - assert(0); + verify(0); } int SyncClusterConnection::_lockType( const string& name ) { @@ -402,7 +402,7 @@ namespace mongo { void SyncClusterConnection::killCursor( long long cursorID ) { // should never need to do this - assert(0); + verify(0); } void SyncClusterConnection::setAllSoTimeouts( double socketTimeout ){ diff --git a/src/mongo/client/syncclusterconnection.h b/src/mongo/client/syncclusterconnection.h index 5ef2b0a547b..b3ed36fe83b 100644 --- a/src/mongo/client/syncclusterconnection.h +++ b/src/mongo/client/syncclusterconnection.h @@ -125,7 +125,7 @@ namespace mongo { public: UpdateNotTheSame( int code , const string& msg , const vector<string>& addrs , const vector<BSONObj>& lastErrors ) : UserException( code , msg ) , _addrs( addrs ) , _lastErrors( lastErrors ) { - assert( _addrs.size() == _lastErrors.size() ); + verify( _addrs.size() == _lastErrors.size() ); } virtual ~UpdateNotTheSame() throw() { diff --git a/src/mongo/client/undef_macros.h b/src/mongo/client/undef_macros.h index 71d0959b8c4..90a818f78f2 100644 --- a/src/mongo/client/undef_macros.h +++ b/src/mongo/client/undef_macros.h @@ -30,11 +30,11 @@ #undef realloc // util/assert_util.h -#undef assert #undef dassert #undef wassert #undef massert #undef uassert +#undef verify #undef DESTRUCTOR_GUARD // util/goodies.h |