| assert_util.h | | assert_util.h | |
| | | | |
| skipping to change at line 173 | | skipping to change at line 173 | |
| | | | |
| /* convert various types of exceptions to strings */ | | /* convert various types of exceptions to strings */ | |
| inline string causedBy( const char* e ){ return (string)" :: caused by
:: " + e; } | | inline string causedBy( const char* e ){ return (string)" :: caused by
:: " + e; } | |
| inline string causedBy( const DBException& e ){ return causedBy( e.toSt
ring().c_str() ); } | | inline string causedBy( const DBException& e ){ return causedBy( e.toSt
ring().c_str() ); } | |
| inline string causedBy( const std::exception& e ){ return causedBy( e.w
hat() ); } | | inline string causedBy( const std::exception& e ){ return causedBy( e.w
hat() ); } | |
| inline string causedBy( const string& e ){ return causedBy( e.c_str() )
; } | | inline string causedBy( const string& e ){ return causedBy( e.c_str() )
; } | |
| | | | |
| /** in the mongodb source, use verify() instead of assert(). verify is
always evaluated even in release builds. */ | | /** in the mongodb source, use verify() instead of assert(). verify is
always evaluated even in release builds. */ | |
| inline void verify( int msgid , bool testOK ) { if ( ! testOK ) verifyF
ailed( msgid ); } | | inline void verify( int msgid , bool testOK ) { if ( ! testOK ) verifyF
ailed( msgid ); } | |
| | | | |
|
| #ifdef assert | | | |
| #undef assert | | | |
| #endif | | | |
| | | | |
| #define MONGO_assert(_Expression) (void)( MONGO_likely(!!(_Expression)) ||
(mongo::asserted(#_Expression, __FILE__, __LINE__), 0) ) | | #define MONGO_assert(_Expression) (void)( MONGO_likely(!!(_Expression)) ||
(mongo::asserted(#_Expression, __FILE__, __LINE__), 0) ) | |
|
| #define assert MONGO_assert | | | |
| | | | |
| /* "user assert". if asserts, user did something wrong, not our code *
/ | | /* "user assert". if asserts, user did something wrong, not our code *
/ | |
| #define MONGO_uassert(msgid, msg, expr) (void)( MONGO_likely(!!(expr)) || (
mongo::uasserted(msgid, msg), 0) ) | | #define MONGO_uassert(msgid, msg, expr) (void)( MONGO_likely(!!(expr)) || (
mongo::uasserted(msgid, msg), 0) ) | |
|
| #define uassert MONGO_uassert | | | |
| | | | |
| /* warning only - keeps going */ | | /* warning only - keeps going */ | |
| #define MONGO_wassert(_Expression) (void)( MONGO_likely(!!(_Expression)) ||
(mongo::wasserted(#_Expression, __FILE__, __LINE__), 0) ) | | #define MONGO_wassert(_Expression) (void)( MONGO_likely(!!(_Expression)) ||
(mongo::wasserted(#_Expression, __FILE__, __LINE__), 0) ) | |
|
| #define wassert MONGO_wassert | | | |
| | | | |
| /* display a message, no context, and throw assertionexception | | /* display a message, no context, and throw assertionexception | |
| | | | |
| easy way to throw an exception and log something without our stack t
race | | easy way to throw an exception and log something without our stack t
race | |
| display happening. | | display happening. | |
| */ | | */ | |
| #define MONGO_massert(msgid, msg, expr) (void)( MONGO_likely(!!(expr)) || (
mongo::msgasserted(msgid, msg), 0) ) | | #define MONGO_massert(msgid, msg, expr) (void)( MONGO_likely(!!(expr)) || (
mongo::msgasserted(msgid, msg), 0) ) | |
|
| #define massert MONGO_massert | | | |
| | | | |
| /* dassert is 'debug assert' -- might want to turn off for production a
s these | | /* dassert is 'debug assert' -- might want to turn off for production a
s these | |
| could be slow. | | could be slow. | |
| */ | | */ | |
| #if defined(_DEBUG) | | #if defined(_DEBUG) | |
| # define MONGO_dassert assert | | # define MONGO_dassert assert | |
| #else | | #else | |
| # define MONGO_dassert(x) | | # define MONGO_dassert(x) | |
| #endif | | #endif | |
|
| #define dassert MONGO_dassert | | | |
| | | | |
| // some special ids that we want to duplicate | | // some special ids that we want to duplicate | |
| | | | |
| // > 10000 asserts | | // > 10000 asserts | |
| // < 10000 UserException | | // < 10000 UserException | |
| | | | |
| enum { ASSERT_ID_DUPKEY = 11000 }; | | enum { ASSERT_ID_DUPKEY = 11000 }; | |
| | | | |
| /* throws a uassertion with an appropriate msg */ | | /* throws a uassertion with an appropriate msg */ | |
| void streamNotGood( int code , string msg , std::ios& myios ) MONGO_NOR
ETURN; | | void streamNotGood( int code , string msg , std::ios& myios ) MONGO_NOR
ETURN; | |
| | | | |
End of changes. 6 change blocks. |
| 9 lines changed or deleted | | 0 lines changed or added | |
|
| cloner.h | | cloner.h | |
| | | | |
| skipping to change at line 37 | | skipping to change at line 37 | |
| * @param useReplAuth - use the credentials we normally use as a replic
ation slave for the cloning | | * @param useReplAuth - use the credentials we normally use as a replic
ation slave for the cloning | |
| * @param snapshot - use $snapshot mode for copying collections. no
te this should not be used when it isn't required, as it will be slower. | | * @param snapshot - use $snapshot mode for copying collections. no
te this should not be used when it isn't required, as it will be slower. | |
| * for example repairDatabase need not use it. | | * for example repairDatabase need not use it. | |
| * @param errCode - If provided, this will be set on error to the s
erver's error code. Currently | | * @param errCode - If provided, this will be set on error to the s
erver's error code. Currently | |
| * this will only be set if there is an error in t
he initial system.namespaces query. | | * this will only be set if there is an error in t
he initial system.namespaces query. | |
| */ | | */ | |
| bool cloneFrom(const char *masterHost, string& errmsg, const string& fr
omdb, bool logForReplication, | | bool cloneFrom(const char *masterHost, string& errmsg, const string& fr
omdb, bool logForReplication, | |
| bool slaveOk, bool useReplAuth, bool snapshot, bool mayY
ield, | | bool slaveOk, bool useReplAuth, bool snapshot, bool mayY
ield, | |
| bool mayBeInterrupted, int *errCode = 0); | | bool mayBeInterrupted, int *errCode = 0); | |
| | | | |
|
| bool copyCollectionFromRemote(const string& host, const string& ns, con
st BSONObj& query, string& errmsg, bool logForRepl, bool mayYield, bool may
BeInterrupted); | | bool copyCollectionFromRemote(const string& host, const string& ns, str
ing& errmsg); | |
| | | | |
| } // namespace mongo | | } // namespace mongo | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 1 lines changed or added | |
|
| connections.h | | connections.h | |
| | | | |
| skipping to change at line 75 | | skipping to change at line 75 | |
| BSONObj findOne(const string &ns, const Query& q, const BSONObj *fi
eldsToReturn = 0, int queryOptions = 0) { | | BSONObj findOne(const string &ns, const Query& q, const BSONObj *fi
eldsToReturn = 0, int queryOptions = 0) { | |
| return conn()->findOne(ns, q, fieldsToReturn, queryOptions); | | return conn()->findOne(ns, q, fieldsToReturn, queryOptions); | |
| } | | } | |
| | | | |
| private: | | private: | |
| auto_ptr<scoped_lock> connLock; | | auto_ptr<scoped_lock> connLock; | |
| static mongo::mutex mapMutex; | | static mongo::mutex mapMutex; | |
| struct X { | | struct X { | |
| mongo::mutex z; | | mongo::mutex z; | |
| DBClientConnection cc; | | DBClientConnection cc; | |
|
| X() : z("X"), cc(/*reconnect*/ true, 0, /*timeout*/ 10.0) { | | bool connected; | |
| | | X() : z("X"), cc(/*reconnect*/ true, 0, /*timeout*/ 10.0), conn | |
| | | ected(false) { | |
| cc._logLevel = 2; | | cc._logLevel = 2; | |
| } | | } | |
| } *x; | | } *x; | |
| typedef map<string,ScopedConn::X*> M; | | typedef map<string,ScopedConn::X*> M; | |
| static M& _map; | | static M& _map; | |
| DBClientConnection* conn() { return &x->cc; } | | DBClientConnection* conn() { return &x->cc; } | |
| const string _hostport; | | const string _hostport; | |
| | | | |
| // we should already be locked... | | // we should already be locked... | |
| bool connect() { | | bool connect() { | |
| string err; | | string err; | |
| if (!x->cc.connect(_hostport, err)) { | | if (!x->cc.connect(_hostport, err)) { | |
| log() << "couldn't connect to " << _hostport << ": " << err <<
rsLog; | | log() << "couldn't connect to " << _hostport << ": " << err <<
rsLog; | |
| return false; | | return false; | |
| } | | } | |
|
| | | x->connected = true; | |
| | | | |
| // if we cannot authenticate against a member, then either its ke
y file | | // if we cannot authenticate against a member, then either its ke
y file | |
| // or our key file has to change. if our key file has to change,
we'll | | // or our key file has to change. if our key file has to change,
we'll | |
| // be rebooting. if their file has to change, they'll be rebooted
so the | | // be rebooting. if their file has to change, they'll be rebooted
so the | |
| // connection created above will go dead, reconnect, and reauth. | | // connection created above will go dead, reconnect, and reauth. | |
| if (!noauth && !x->cc.auth("local", internalSecurity.user, intern
alSecurity.pwd, err, false)) { | | if (!noauth && !x->cc.auth("local", internalSecurity.user, intern
alSecurity.pwd, err, false)) { | |
| log() << "could not authenticate against " << _hostport << ", "
<< err << rsLog; | | log() << "could not authenticate against " << _hostport << ", "
<< err << rsLog; | |
| return false; | | return false; | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 116 | | skipping to change at line 118 | |
| bool first = false; | | bool first = false; | |
| { | | { | |
| scoped_lock lk(mapMutex); | | scoped_lock lk(mapMutex); | |
| x = _map[_hostport]; | | x = _map[_hostport]; | |
| if( x == 0 ) { | | if( x == 0 ) { | |
| x = _map[_hostport] = new X(); | | x = _map[_hostport] = new X(); | |
| first = true; | | first = true; | |
| connLock.reset( new scoped_lock(x->z) ); | | connLock.reset( new scoped_lock(x->z) ); | |
| } | | } | |
| } | | } | |
|
| if( !first ) { | | | |
| connLock.reset( new scoped_lock(x->z) ); | | // already locked connLock above | |
| | | if (first) { | |
| | | connect(); | |
| | | return; | |
| | | } | |
| | | | |
| | | connLock.reset( new scoped_lock(x->z) ); | |
| | | if (x->connected) { | |
| return; | | return; | |
| } | | } | |
| | | | |
|
| | | // Keep trying to connect if we're not yet connected | |
| connect(); | | connect(); | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
End of changes. 4 change blocks. |
| 3 lines changed or deleted | | 14 lines changed or added | |
|
| dbclient_rs.h | | dbclient_rs.h | |
| | | | |
| skipping to change at line 27 | | skipping to change at line 27 | |
| | | | |
| #pragma once | | #pragma once | |
| | | | |
| #include "../pch.h" | | #include "../pch.h" | |
| #include "dbclient.h" | | #include "dbclient.h" | |
| | | | |
| namespace mongo { | | namespace mongo { | |
| | | | |
| class ReplicaSetMonitor; | | class ReplicaSetMonitor; | |
| typedef shared_ptr<ReplicaSetMonitor> ReplicaSetMonitorPtr; | | typedef shared_ptr<ReplicaSetMonitor> ReplicaSetMonitorPtr; | |
|
| | | typedef pair<set<string>,set<int> > NodeDiff; | |
| | | | |
| /** | | /** | |
| * manages state about a replica set for client | | * manages state about a replica set for client | |
| * keeps tabs on whose master and what slaves are up | | * keeps tabs on whose master and what slaves are up | |
| * can hand a slave to someone for SLAVE_OK | | * can hand a slave to someone for SLAVE_OK | |
| * one instace per process per replica set | | * one instace per process per replica set | |
| * TODO: we might be able to use a regular Node * to avoid _lock | | * TODO: we might be able to use a regular Node * to avoid _lock | |
| */ | | */ | |
| class ReplicaSetMonitor { | | class ReplicaSetMonitor { | |
| public: | | public: | |
| | | | |
| skipping to change at line 107 | | skipping to change at line 108 | |
| | | | |
| private: | | private: | |
| /** | | /** | |
| * This populates a list of hosts from the list of seeds (discardin
g the | | * This populates a list of hosts from the list of seeds (discardin
g the | |
| * seed list). | | * seed list). | |
| * @param name set name | | * @param name set name | |
| * @param servers seeds | | * @param servers seeds | |
| */ | | */ | |
| ReplicaSetMonitor( const string& name , const vector<HostAndPort>&
servers ); | | ReplicaSetMonitor( const string& name , const vector<HostAndPort>&
servers ); | |
| | | | |
|
| | | /** | |
| | | * Checks all connections from the host list and sets the current | |
| | | * master. | |
| | | * | |
| | | * @param checkAllSecondaries if set to false, stop immediately whe | |
| | | n | |
| | | * the master is found or when _master is not -1. | |
| | | */ | |
| void _check( bool checkAllSecondaries ); | | void _check( bool checkAllSecondaries ); | |
| | | | |
| /** | | /** | |
| * Use replSetGetStatus command to make sure hosts in host list are
up | | * Use replSetGetStatus command to make sure hosts in host list are
up | |
| * and readable. Sets Node::ok appropriately. | | * and readable. Sets Node::ok appropriately. | |
| */ | | */ | |
| void _checkStatus(DBClientConnection *conn); | | void _checkStatus(DBClientConnection *conn); | |
| | | | |
| /** | | /** | |
| * Add array of hosts to host list. Doesn't do anything if hosts ar
e | | * Add array of hosts to host list. Doesn't do anything if hosts ar
e | |
| * already in host list. | | * already in host list. | |
| * @param hostList the list of hosts to add | | * @param hostList the list of hosts to add | |
| * @param changed if new hosts were added | | * @param changed if new hosts were added | |
| */ | | */ | |
| void _checkHosts(const BSONObj& hostList, bool& changed); | | void _checkHosts(const BSONObj& hostList, bool& changed); | |
| | | | |
| /** | | /** | |
| * Updates host list. | | * Updates host list. | |
|
| * @param c the connection to check | | * Invariant: if nodesOffset is >= 0, _nodes[nodesOffset].conn shou | |
| | | ld be | |
| | | * equal to conn. | |
| | | * | |
| | | * @param conn the connection to check | |
| * @param maybePrimary OUT | | * @param maybePrimary OUT | |
| * @param verbose | | * @param verbose | |
| * @param nodesOffset - offset into _nodes array, -1 for not in it | | * @param nodesOffset - offset into _nodes array, -1 for not in it | |
|
| * @return if the connection is good | | * | |
| | | * @return true if the connection is good or false if invariant | |
| | | * is broken | |
| */ | | */ | |
|
| bool _checkConnection( DBClientConnection * c , string& maybePrimar | | bool _checkConnection( DBClientConnection* conn, string& maybePrima | |
| y , bool verbose , int nodesOffset ); | | ry, | |
| | | bool verbose, int nodesOffset ); | |
| | | | |
| | | string _getServerAddress_inlock() const; | |
| | | | |
| | | NodeDiff _getHostDiff_inlock( const BSONObj& hostList ); | |
| | | bool _shouldChangeHosts( const BSONObj& hostList, bool inlock ); | |
| | | | |
|
| | | /** | |
| | | * @return the index to _nodes corresponding to the server address. | |
| | | */ | |
| int _find( const string& server ) const ; | | int _find( const string& server ) const ; | |
| int _find_inlock( const string& server ) const ; | | int _find_inlock( const string& server ) const ; | |
|
| int _find( const HostAndPort& server ) const ; | | | |
| | | | |
|
| mutable mongo::mutex _lock; // protects _nodes | | /** | |
| | | * Checks whether the given connection matches the connection store | |
| | | d in _nodes. | |
| | | * Mainly used for sanity checking to confirm that nodeOffset still | |
| | | * refers to the right connection after releasing and reacquiring | |
| | | * a mutex. | |
| | | */ | |
| | | bool _checkConnMatch_inlock( DBClientConnection* conn, size_t nodeO | |
| | | ffset ) const; | |
| | | | |
| | | // protects _nodes and indices pointing to it (_master & _nextSlave | |
| | | ) | |
| | | mutable mongo::mutex _lock; | |
| | | | |
| | | /** | |
| | | * "Synchronizes" the _checkConnection method. Should ideally be on | |
| | | e mutex per | |
| | | * connection object being used. The purpose of this lock is to mak | |
| | | e sure that | |
| | | * the reply from the connection the lock holder got is the actual | |
| | | response | |
| | | * to what it sent. | |
| | | * | |
| | | * Deadlock WARNING: never acquire this while holding _lock | |
| | | */ | |
| mutable mongo::mutex _checkConnectionLock; | | mutable mongo::mutex _checkConnectionLock; | |
| | | | |
| string _name; | | string _name; | |
| struct Node { | | struct Node { | |
| Node( const HostAndPort& a , DBClientConnection* c ) | | Node( const HostAndPort& a , DBClientConnection* c ) | |
| : addr( a ) , conn(c) , ok(true) , | | : addr( a ) , conn(c) , ok(true) , | |
| ismaster(false), secondary( false ) , hidden( false ) , p
ingTimeMillis(0) { | | ismaster(false), secondary( false ) , hidden( false ) , p
ingTimeMillis(0) { | |
|
| | | ok = conn.get() == NULL; | |
| } | | } | |
| | | | |
| bool okForSecondaryQueries() const { | | bool okForSecondaryQueries() const { | |
| return ok && secondary && ! hidden; | | return ok && secondary && ! hidden; | |
| } | | } | |
| | | | |
| BSONObj toBSON() const { | | BSONObj toBSON() const { | |
| return BSON( "addr" << addr.toString() << | | return BSON( "addr" << addr.toString() << | |
| "isMaster" << ismaster << | | "isMaster" << ismaster << | |
| "secondary" << secondary << | | "secondary" << secondary << | |
| | | | |
End of changes. 9 change blocks. |
| 6 lines changed or deleted | | 54 lines changed or added | |
|
| dur_commitjob.h | | dur_commitjob.h | |
| | | | |
| skipping to change at line 167 | | skipping to change at line 167 | |
| concurrency: assumption is caller is appropriately locking. | | concurrency: assumption is caller is appropriately locking. | |
| for example note() invocations are from the write
lock. | | for example note() invocations are from the write
lock. | |
| other uses are in a read lock from a single thread
(durThread) | | other uses are in a read lock from a single thread
(durThread) | |
| */ | | */ | |
| class CommitJob : boost::noncopyable { | | class CommitJob : boost::noncopyable { | |
| public: | | public: | |
| AlignedBuilder _ab; // for direct i/o writes to journal | | AlignedBuilder _ab; // for direct i/o writes to journal | |
| | | | |
| CommitJob(); | | CommitJob(); | |
| | | | |
|
| | | ~CommitJob(){ assert(!"shouldn't destroy CommitJob!"); } | |
| | | | |
| /** record/note an intent to write */ | | /** record/note an intent to write */ | |
| void note(void* p, int len); | | void note(void* p, int len); | |
| | | | |
| /** note an operation other than a "basic write" */ | | /** note an operation other than a "basic write" */ | |
| void noteOp(shared_ptr<DurOp> p); | | void noteOp(shared_ptr<DurOp> p); | |
| | | | |
| set<WriteIntent>& writes() { | | set<WriteIntent>& writes() { | |
| if( !_wi._drained ) { | | if( !_wi._drained ) { | |
| // generally, you don't want to use the set until it is
prepared (after deferred ops are applied) | | // generally, you don't want to use the set until it is
prepared (after deferred ops are applied) | |
| // thus this assert here. | | // thus this assert here. | |
| | | | |
| skipping to change at line 215 | | skipping to change at line 217 | |
| private: | | private: | |
| NotifyAll::When _commitNumber; | | NotifyAll::When _commitNumber; | |
| bool _hasWritten; | | bool _hasWritten; | |
| Writes _wi; // todo: fix name | | Writes _wi; // todo: fix name | |
| size_t _bytes; | | size_t _bytes; | |
| public: | | public: | |
| NotifyAll _notify; // for getlasterror fsync:true acknowledgeme
nts | | NotifyAll _notify; // for getlasterror fsync:true acknowledgeme
nts | |
| unsigned _nSinceCommitIfNeededCall; | | unsigned _nSinceCommitIfNeededCall; | |
| }; | | }; | |
| | | | |
|
| extern CommitJob commitJob; | | extern CommitJob& commitJob; | |
| | | | |
| } | | } | |
| } | | } | |
| | | | |
End of changes. 2 change blocks. |
| 1 lines changed or deleted | | 3 lines changed or added | |
|
| goodies.h | | goodies.h | |
| | | | |
| skipping to change at line 327 | | skipping to change at line 327 | |
| | | | |
| class TicketHolder { | | class TicketHolder { | |
| public: | | public: | |
| TicketHolder( int num ) : _mutex("TicketHolder") { | | TicketHolder( int num ) : _mutex("TicketHolder") { | |
| _outof = num; | | _outof = num; | |
| _num = num; | | _num = num; | |
| } | | } | |
| | | | |
| bool tryAcquire() { | | bool tryAcquire() { | |
| scoped_lock lk( _mutex ); | | scoped_lock lk( _mutex ); | |
|
| if ( _num <= 0 ) { | | return _tryAcquire(); | |
| if ( _num < 0 ) { | | } | |
| cerr << "DISASTER! in TicketHolder" << endl; | | | |
| } | | void waitForTicket() { | |
| return false; | | scoped_lock lk( _mutex ); | |
| | | | |
| | | while( ! _tryAcquire() ) { | |
| | | _newTicket.wait( lk.boost() ); | |
| } | | } | |
|
| _num--; | | | |
| return true; | | | |
| } | | } | |
| | | | |
| void release() { | | void release() { | |
|
| scoped_lock lk( _mutex ); | | { | |
| _num++; | | scoped_lock lk( _mutex ); | |
| | | _num++; | |
| | | } | |
| | | _newTicket.notify_one(); | |
| } | | } | |
| | | | |
| void resize( int newSize ) { | | void resize( int newSize ) { | |
|
| scoped_lock lk( _mutex ); | | { | |
| int used = _outof - _num; | | scoped_lock lk( _mutex ); | |
| if ( used > newSize ) { | | | |
| cout << "ERROR: can't resize since we're using (" << used < | | int used = _outof - _num; | |
| < ") more than newSize(" << newSize << ")" << endl; | | if ( used > newSize ) { | |
| return; | | cout << "ERROR: can't resize since we're using (" << us | |
| | | ed << ") more than newSize(" << newSize << ")" << endl; | |
| | | return; | |
| | | } | |
| | | | |
| | | _outof = newSize; | |
| | | _num = _outof - used; | |
| } | | } | |
| | | | |
|
| _outof = newSize; | | // Potentially wasteful, but easier to see is correct | |
| _num = _outof - used; | | _newTicket.notify_all(); | |
| } | | } | |
| | | | |
| int available() const { | | int available() const { | |
| return _num; | | return _num; | |
| } | | } | |
| | | | |
| int used() const { | | int used() const { | |
| return _outof - _num; | | return _outof - _num; | |
| } | | } | |
| | | | |
| int outof() const { return _outof; } | | int outof() const { return _outof; } | |
| | | | |
| private: | | private: | |
|
| | | | |
| | | bool _tryAcquire(){ | |
| | | if ( _num <= 0 ) { | |
| | | if ( _num < 0 ) { | |
| | | cerr << "DISASTER! in TicketHolder" << endl; | |
| | | } | |
| | | return false; | |
| | | } | |
| | | _num--; | |
| | | return true; | |
| | | } | |
| | | | |
| int _outof; | | int _outof; | |
| int _num; | | int _num; | |
| mongo::mutex _mutex; | | mongo::mutex _mutex; | |
|
| | | boost::condition_variable_any _newTicket; | |
| }; | | }; | |
| | | | |
| class TicketHolderReleaser { | | class TicketHolderReleaser { | |
| public: | | public: | |
| TicketHolderReleaser( TicketHolder * holder ) { | | TicketHolderReleaser( TicketHolder * holder ) { | |
| _holder = holder; | | _holder = holder; | |
| } | | } | |
| | | | |
| ~TicketHolderReleaser() { | | ~TicketHolderReleaser() { | |
| _holder->release(); | | _holder->release(); | |
| | | | |
End of changes. 7 change blocks. |
| 17 lines changed or deleted | | 40 lines changed or added | |
|
| pch.h | | pch.h | |
| | | | |
| skipping to change at line 100 | | skipping to change at line 100 | |
| #include "boost/function.hpp" | | #include "boost/function.hpp" | |
| #include <boost/thread/tss.hpp> | | #include <boost/thread/tss.hpp> | |
| #include "boost/detail/endian.hpp" | | #include "boost/detail/endian.hpp" | |
| #define BOOST_SPIRIT_THREADSAFE | | #define BOOST_SPIRIT_THREADSAFE | |
| #include <boost/version.hpp> | | #include <boost/version.hpp> | |
| #include <boost/tuple/tuple.hpp> | | #include <boost/tuple/tuple.hpp> | |
| #include <boost/thread/thread.hpp> | | #include <boost/thread/thread.hpp> | |
| #include <boost/thread/condition.hpp> | | #include <boost/thread/condition.hpp> | |
| #include <boost/thread/recursive_mutex.hpp> | | #include <boost/thread/recursive_mutex.hpp> | |
| #include <boost/thread/xtime.hpp> | | #include <boost/thread/xtime.hpp> | |
|
| #undef assert | | | |
| #define assert MONGO_assert | | | |
| | | | |
| namespace mongo { | | namespace mongo { | |
| | | | |
| using namespace std; | | using namespace std; | |
| using boost::shared_ptr; | | using boost::shared_ptr; | |
| | | | |
| #if defined(_DEBUG) | | #if defined(_DEBUG) | |
| const bool debug=true; | | const bool debug=true; | |
| #else | | #else | |
| const bool debug=false; | | const bool debug=false; | |
| | | | |
| skipping to change at line 153 | | skipping to change at line 151 | |
| you should either use dbexit to shutdown cleanly, or ::exit to tell
the system to quit | | you should either use dbexit to shutdown cleanly, or ::exit to tell
the system to quit | |
| if you use this, you'll get a link error since mongo::exit isn't def
ined | | if you use this, you'll get a link error since mongo::exit isn't def
ined | |
| */ | | */ | |
| void exit( ExitCode returnCode ); | | void exit( ExitCode returnCode ); | |
| bool inShutdown(); | | bool inShutdown(); | |
| | | | |
| using namespace boost::filesystem; | | using namespace boost::filesystem; | |
| void asserted(const char *msg, const char *file, unsigned line); | | void asserted(const char *msg, const char *file, unsigned line); | |
| } | | } | |
| | | | |
|
| | | #include "util/allocator.h" | |
| | | #include "client/redef_macros.h" | |
| | | | |
| // TODO: Rework the headers so we don't need this craziness | | // TODO: Rework the headers so we don't need this craziness | |
| #include "bson/inline_decls.h" | | #include "bson/inline_decls.h" | |
| #define MONGO_assert(_Expression) (void)( MONGO_likely(!!(_Expression)) ||
(mongo::asserted(#_Expression, __FILE__, __LINE__), 0) ) | | #define MONGO_assert(_Expression) (void)( MONGO_likely(!!(_Expression)) ||
(mongo::asserted(#_Expression, __FILE__, __LINE__), 0) ) | |
| | | | |
| #include "util/debug_util.h" | | #include "util/debug_util.h" | |
| #include "util/goodies.h" | | #include "util/goodies.h" | |
| #include "util/log.h" | | #include "util/log.h" | |
|
| #include "util/allocator.h" | | | |
| #include "util/assert_util.h" | | #include "util/assert_util.h" | |
| | | | |
| namespace mongo { | | namespace mongo { | |
| | | | |
| void sayDbContext(const char *msg = 0); | | void sayDbContext(const char *msg = 0); | |
| void rawOut( const string &s ); | | void rawOut( const string &s ); | |
| | | | |
| typedef char _TCHAR; | | typedef char _TCHAR; | |
| | | | |
| using boost::uint32_t; | | using boost::uint32_t; | |
| | | | |
End of changes. 3 change blocks. |
| 3 lines changed or deleted | | 4 lines changed or added | |
|
| pdfile.h | | pdfile.h | |
| | | | |
| skipping to change at line 316 | | skipping to change at line 316 | |
| assert( dl.sameFile(myLoc) ); | | assert( dl.sameFile(myLoc) ); | |
| int x = dl.getOfs() - myLoc.getOfs(); | | int x = dl.getOfs() - myLoc.getOfs(); | |
| assert( x > 0 ); | | assert( x > 0 ); | |
| return (Record *) (((char *) this) + x); | | return (Record *) (((char *) this) + x); | |
| } | | } | |
| | | | |
| Extent* getNextExtent() { return xnext.isNull() ? 0 : DataFileMgr::
getExtent(xnext); } | | Extent* getNextExtent() { return xnext.isNull() ? 0 : DataFileMgr::
getExtent(xnext); } | |
| Extent* getPrevExtent() { return xprev.isNull() ? 0 : DataFileMgr::
getExtent(xprev); } | | Extent* getPrevExtent() { return xprev.isNull() ? 0 : DataFileMgr::
getExtent(xprev); } | |
| | | | |
| static int maxSize(); | | static int maxSize(); | |
|
| static int minSize() { return 0x100; } | | static int minSize() { return 0x1000; } | |
| /** | | /** | |
| * @param len lengt of record we need | | * @param len lengt of record we need | |
| * @param lastRecord size of last extent which is a factor in next
extent size | | * @param lastRecord size of last extent which is a factor in next
extent size | |
| */ | | */ | |
| static int followupSize(int len, int lastExtentLen); | | static int followupSize(int len, int lastExtentLen); | |
| | | | |
| /** get a suggested size for the first extent in a namespace | | /** get a suggested size for the first extent in a namespace | |
| * @param len length of record we need to insert | | * @param len length of record we need to insert | |
| */ | | */ | |
| static int initialSize(int len); | | static int initialSize(int len); | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 1 lines changed or added | |
|
| redef_macros.h | | redef_macros.h | |
|
| /** @file redef_macros.h macros the implementation uses. | | /** @file redef_macros.h macros for mongo internals | |
| | | | |
| @see undef_macros.h undefines these after use to minimize name pollutio
n. | | @see undef_macros.h undefines these after use to minimize name pollutio
n. | |
| */ | | */ | |
| | | | |
| /* Copyright 2009 10gen Inc. | | /* Copyright 2009 10gen Inc. | |
| * | | * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | | * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | | * You may obtain a copy of the License at | |
| * | | * | |
| | | | |
| skipping to change at line 23 | | skipping to change at line 23 | |
| * | | * | |
| * Unless required by applicable law or agreed to in writing, software | | * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, | | * distributed under the License is distributed on an "AS IS" BASIS, | |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impli
ed. | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impli
ed. | |
| * See the License for the specific language governing permissions and | | * See the License for the specific language governing permissions and | |
| * limitations under the License. | | * limitations under the License. | |
| */ | | */ | |
| | | | |
| // If you define a new global un-prefixed macro, please add it here and in
undef_macros | | // If you define a new global un-prefixed macro, please add it here and in
undef_macros | |
| | | | |
|
| // #pragma once // this file is intended to be processed multiple times | | #define MONGO_MACROS_PUSHED 1 | |
| | | | |
| #if defined(MONGO_MACROS_CLEANED) | | | |
| | | | |
| // util/allocator.h | | // util/allocator.h | |
|
| | | #pragma push_macro("malloc") | |
| | | #undef malloc | |
| #define malloc MONGO_malloc | | #define malloc MONGO_malloc | |
|
| | | #pragma push_macro("realloc") | |
| | | #undef realloc | |
| #define realloc MONGO_realloc | | #define realloc MONGO_realloc | |
| | | | |
| // util/assert_util.h | | // util/assert_util.h | |
|
| | | #pragma push_macro("assert") | |
| | | #undef assert | |
| #define assert MONGO_assert | | #define assert MONGO_assert | |
|
| | | #pragma push_macro("verify") | |
| | | #undef verify | |
| | | #define verify MONGO_verify | |
| | | #pragma push_macro("dassert") | |
| | | #undef dassert | |
| #define dassert MONGO_dassert | | #define dassert MONGO_dassert | |
|
| | | #pragma push_macro("wassert") | |
| | | #undef wassert | |
| #define wassert MONGO_wassert | | #define wassert MONGO_wassert | |
|
| | | #pragma push_macro("massert") | |
| | | #undef massert | |
| #define massert MONGO_massert | | #define massert MONGO_massert | |
|
| | | #pragma push_macro("uassert") | |
| | | #undef uassert | |
| #define uassert MONGO_uassert | | #define uassert MONGO_uassert | |
| #define BOOST_CHECK_EXCEPTION MONGO_BOOST_CHECK_EXCEPTION | | #define BOOST_CHECK_EXCEPTION MONGO_BOOST_CHECK_EXCEPTION | |
|
| | | #pragma push_macro("DESTRUCTOR_GUARD") | |
| | | #undef DESTRUCTOR_GUARD | |
| #define DESTRUCTOR_GUARD MONGO_DESTRUCTOR_GUARD | | #define DESTRUCTOR_GUARD MONGO_DESTRUCTOR_GUARD | |
| | | | |
| // util/goodies.h | | // util/goodies.h | |
|
| | | #pragma push_macro("PRINT") | |
| | | #undef PRINT | |
| #define PRINT MONGO_PRINT | | #define PRINT MONGO_PRINT | |
|
| | | #pragma push_macro("PRINTFL") | |
| | | #undef PRINTFL | |
| #define PRINTFL MONGO_PRINTFL | | #define PRINTFL MONGO_PRINTFL | |
|
| | | #pragma push_macro("asctime") | |
| | | #undef asctime | |
| #define asctime MONGO_asctime | | #define asctime MONGO_asctime | |
|
| | | #pragma push_macro("gmtime") | |
| | | #undef gmtime | |
| #define gmtime MONGO_gmtime | | #define gmtime MONGO_gmtime | |
|
| | | #pragma push_macro("localtime") | |
| | | #undef localtime | |
| #define localtime MONGO_localtime | | #define localtime MONGO_localtime | |
|
| | | #pragma push_macro("ctime") | |
| | | #undef ctime | |
| #define ctime MONGO_ctime | | #define ctime MONGO_ctime | |
| | | | |
| // util/debug_util.h | | // util/debug_util.h | |
|
| | | #pragma push_macro("DEV") | |
| | | #undef DEV | |
| #define DEV MONGO_DEV | | #define DEV MONGO_DEV | |
|
| | | #pragma push_macro("DEBUGGING") | |
| | | #undef DEBUGGING | |
| #define DEBUGGING MONGO_DEBUGGING | | #define DEBUGGING MONGO_DEBUGGING | |
|
| | | #pragma push_macro("SOMETIMES") | |
| | | #undef SOMETIMES | |
| #define SOMETIMES MONGO_SOMETIMES | | #define SOMETIMES MONGO_SOMETIMES | |
|
| | | #pragma push_macro("OCCASIONALLY") | |
| | | #undef OCCASIONALLY | |
| #define OCCASIONALLY MONGO_OCCASIONALLY | | #define OCCASIONALLY MONGO_OCCASIONALLY | |
|
| | | #pragma push_macro("RARELY") | |
| | | #undef RARELY | |
| #define RARELY MONGO_RARELY | | #define RARELY MONGO_RARELY | |
|
| | | #pragma push_macro("ONCE") | |
| | | #undef ONCE | |
| #define ONCE MONGO_ONCE | | #define ONCE MONGO_ONCE | |
| | | | |
| // util/log.h | | // util/log.h | |
|
| | | #pragma push_macro("LOG") | |
| | | #undef LOG | |
| #define LOG MONGO_LOG | | #define LOG MONGO_LOG | |
|
| | | | |
| #undef MONGO_MACROS_CLEANED | | | |
| #endif | | | |
| | | | |
End of changes. 24 change blocks. |
| 4 lines changed or deleted | | 47 lines changed or added | |
|
| rs_config.h | | rs_config.h | |
| | | | |
| skipping to change at line 138 | | skipping to change at line 138 | |
| void saveConfigLocally(BSONObj comment); // to local db | | void saveConfigLocally(BSONObj comment); // to local db | |
| string saveConfigEverywhere(); // returns textual info on what happ
ened | | string saveConfigEverywhere(); // returns textual info on what happ
ened | |
| | | | |
| /** | | /** | |
| * Update members' groups when the config changes but members stay
the same. | | * Update members' groups when the config changes but members stay
the same. | |
| */ | | */ | |
| void updateMembers(List1<Member> &dest); | | void updateMembers(List1<Member> &dest); | |
| | | | |
| BSONObj asBson() const; | | BSONObj asBson() const; | |
| | | | |
|
| | | /** | |
| | | * Getter and setter for _majority. This is almost always | |
| | | * members.size()/2+1, but can be the number of non-arbiter members | |
| | | if | |
| | | * there are more arbiters than non-arbiters (writing to 3 out of 7 | |
| | | * servers is safe if 4 of the servers are arbiters). | |
| | | */ | |
| | | void setMajority(); | |
| | | int getMajority() const; | |
| | | | |
| bool _constructed; | | bool _constructed; | |
| private: | | private: | |
| bool _ok; | | bool _ok; | |
|
| | | int _majority; | |
| | | | |
| void from(BSONObj); | | void from(BSONObj); | |
| void clear(); | | void clear(); | |
| | | | |
| struct TagClause; | | struct TagClause; | |
| | | | |
| /** | | /** | |
| * This is a logical grouping of servers. It is pointed to by a se
t of | | * This is a logical grouping of servers. It is pointed to by a se
t of | |
| * servers with a certain tag. | | * servers with a certain tag. | |
| * | | * | |
| * For example, suppose servers A, B, and C have the tag "dc" : "ny
c". If we | | * For example, suppose servers A, B, and C have the tag "dc" : "ny
c". If we | |
| | | | |
End of changes. 2 change blocks. |
| 0 lines changed or deleted | | 12 lines changed or added | |
|
| security_common.h | | security_common.h | |
| | | | |
| skipping to change at line 60 | | skipping to change at line 60 | |
| | | | |
| class CmdAuthenticate : public Command { | | class CmdAuthenticate : public Command { | |
| public: | | public: | |
| virtual bool requiresAuth() { return false; } | | virtual bool requiresAuth() { return false; } | |
| virtual bool logTheOp() { | | virtual bool logTheOp() { | |
| return false; | | return false; | |
| } | | } | |
| virtual bool slaveOk() const { | | virtual bool slaveOk() const { | |
| return true; | | return true; | |
| } | | } | |
|
| virtual LockType locktype() const { return READ; } | | virtual LockType locktype() const { return NONE; } | |
| virtual void help(stringstream& ss) const { ss << "internal"; } | | virtual void help(stringstream& ss) const { ss << "internal"; } | |
| CmdAuthenticate() : Command("authenticate") {} | | CmdAuthenticate() : Command("authenticate") {} | |
| bool run(const string& dbname , BSONObj& cmdObj, int options, strin
g& errmsg, BSONObjBuilder& result, bool fromRepl); | | bool run(const string& dbname , BSONObj& cmdObj, int options, strin
g& errmsg, BSONObjBuilder& result, bool fromRepl); | |
| private: | | private: | |
| bool getUserObj(const string& dbname, const string& user, BSONObj&
userObj, string& pwd); | | bool getUserObj(const string& dbname, const string& user, BSONObj&
userObj, string& pwd); | |
| void authenticate(const string& dbname, const string& user, const b
ool readOnly); | | void authenticate(const string& dbname, const string& user, const b
ool readOnly); | |
| }; | | }; | |
| | | | |
| class CmdLogout : public Command { | | class CmdLogout : public Command { | |
| public: | | public: | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 1 lines changed or added | |
|
| undef_macros.h | | undef_macros.h | |
| | | | |
| skipping to change at line 22 | | skipping to change at line 22 | |
| * distributed under the License is distributed on an "AS IS" BASIS, | | * distributed under the License is distributed on an "AS IS" BASIS, | |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impli
ed. | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impli
ed. | |
| * See the License for the specific language governing permissions and | | * See the License for the specific language governing permissions and | |
| * limitations under the License. | | * limitations under the License. | |
| */ | | */ | |
| | | | |
| // If you define a new global un-prefixed macro, please add it here and in
redef_macros | | // If you define a new global un-prefixed macro, please add it here and in
redef_macros | |
| | | | |
| // #pragma once // this file is intended to be processed multiple times | | // #pragma once // this file is intended to be processed multiple times | |
| | | | |
|
| /** MONGO_EXPOSE_MACROS - when defined, indicates that you are compiling a | | #if !defined (MONGO_EXPOSE_MACROS) | |
| mongo program rather | | | |
| than just using the C++ driver. | | #ifdef MONGO_MACROS_PUSHED | |
| */ | | | |
| #if !defined(MONGO_EXPOSE_MACROS) && !defined(MONGO_MACROS_CLEANED) | | | |
| | | | |
| // util/allocator.h | | // util/allocator.h | |
| #undef malloc | | #undef malloc | |
|
| | | #pragma pop_macro("malloc") | |
| #undef realloc | | #undef realloc | |
|
| | | #pragma pop_macro("realloc") | |
| | | | |
| // util/assert_util.h | | // util/assert_util.h | |
| #undef assert | | #undef assert | |
|
| | | #pragma pop_macro("assert") | |
| #undef dassert | | #undef dassert | |
|
| | | #pragma pop_macro("dassert") | |
| #undef wassert | | #undef wassert | |
|
| | | #pragma pop_macro("wassert") | |
| #undef massert | | #undef massert | |
|
| | | #pragma pop_macro("massert") | |
| #undef uassert | | #undef uassert | |
|
| | | #pragma pop_macro("uassert") | |
| #undef BOOST_CHECK_EXCEPTION | | #undef BOOST_CHECK_EXCEPTION | |
|
| | | #undef verify | |
| | | #pragma pop_macro("verify") | |
| #undef DESTRUCTOR_GUARD | | #undef DESTRUCTOR_GUARD | |
|
| | | #pragma pop_macro("DESTRUCTOR_GUARD") | |
| | | | |
| // util/goodies.h | | // util/goodies.h | |
| #undef PRINT | | #undef PRINT | |
|
| | | #pragma pop_macro("PRINT") | |
| #undef PRINTFL | | #undef PRINTFL | |
|
| | | #pragma pop_macro("PRINTFL") | |
| #undef asctime | | #undef asctime | |
|
| | | #pragma pop_macro("asctime") | |
| #undef gmtime | | #undef gmtime | |
|
| | | #pragma pop_macro("gmtime") | |
| #undef localtime | | #undef localtime | |
|
| | | #pragma pop_macro("localtime") | |
| #undef ctime | | #undef ctime | |
|
| | | #pragma pop_macro("ctime") | |
| | | | |
| // util/debug_util.h | | // util/debug_util.h | |
| #undef DEV | | #undef DEV | |
|
| | | #pragma pop_macro("DEV") | |
| #undef DEBUGGING | | #undef DEBUGGING | |
|
| | | #pragma pop_macro("DEBUGGING") | |
| #undef SOMETIMES | | #undef SOMETIMES | |
|
| | | #pragma pop_macro("SOMETIMES") | |
| #undef OCCASIONALLY | | #undef OCCASIONALLY | |
|
| | | #pragma pop_macro("OCCASIONALLY") | |
| #undef RARELY | | #undef RARELY | |
|
| | | #pragma pop_macro("RARELY") | |
| #undef ONCE | | #undef ONCE | |
|
| | | #pragma pop_macro("ONCE") | |
| | | | |
| // util/log.h | | // util/log.h | |
| #undef LOG | | #undef LOG | |
|
| | | #pragma pop_macro("LOG") | |
| | | | |
|
| #define MONGO_MACROS_CLEANED | | #undef MONGO_MACROS_PUSHED | |
| | | #endif | |
| #endif | | #endif | |
| | | | |
End of changes. 24 change blocks. |
| 6 lines changed or deleted | | 28 lines changed or added | |
|