builder.h   builder.h 
skipping to change at line 20 skipping to change at line 20
* *
* 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.
*/ */
#pragma once #pragma once
#include <cfloat>
#include <string> #include <string>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "../inline_decls.h" #include "../inline_decls.h"
#include "../stringdata.h" #include "../stringdata.h"
namespace mongo { namespace mongo {
/* Note the limit here is rather arbitrary and is simply a standard. ge nerally the code works /* Note the limit here is rather arbitrary and is simply a standard. ge nerally the code works
with any object that fits in ram. with any object that fits in ram.
Also note that the server has some basic checks to enforce this limi t but those checks are not exhaustive Also note that the server has some basic checks to enforce this limi t but those checks are not exhaustive
for example need to check for size too big after for example need to check for size too big after
update $push (append) operation update $push (append) operation
various db.eval() type operations various db.eval() type operations
*/ */
const int BSONObjMaxUserSize = 16 * 1024 * 1024; const int BSONObjMaxUserSize = 16 * 1024 * 1024;
/* /*
Sometimeswe we need objects slightly larger - an object in the repli cation local.oplog Sometimes we need objects slightly larger - an object in the replica tion local.oplog
is slightly larger than a user object for example. is slightly larger than a user object for example.
*/ */
const int BSONObjMaxInternalSize = BSONObjMaxUserSize + ( 16 * 1024 ); const int BSONObjMaxInternalSize = BSONObjMaxUserSize + ( 16 * 1024 );
const int BufferMaxSize = 64 * 1024 * 1024; const int BufferMaxSize = 64 * 1024 * 1024;
class StringBuilder; class StringBuilder;
void msgasserted(int msgid, const char *msg); void msgasserted(int msgid, const char *msg);
skipping to change at line 233 skipping to change at line 234
While designed to be a variable on the stack, if you were to dynami cally allocate one, While designed to be a variable on the stack, if you were to dynami cally allocate one,
nothing bad would happen. In fact in some circumstances this mig ht make sense, say, nothing bad would happen. In fact in some circumstances this mig ht make sense, say,
embedded in some other object. embedded in some other object.
*/ */
class StackBufBuilder : public _BufBuilder<StackAllocator> { class StackBufBuilder : public _BufBuilder<StackAllocator> {
public: public:
StackBufBuilder() : _BufBuilder<StackAllocator>(StackAllocator::SZ) { } StackBufBuilder() : _BufBuilder<StackAllocator>(StackAllocator::SZ) { }
void decouple(); // not allowed. not implemented. void decouple(); // not allowed. not implemented.
}; };
namespace {
#if defined(_WIN32) #if defined(_WIN32)
#pragma warning( push ) int (*mongo_snprintf)(char *str, size_t size, const char *format, .
// warning C4996: 'sprintf': This function or variable may be unsafe. Consi ..) = &sprintf_s;
der using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WAR #else
NINGS. int (*mongo_snprintf)(char *str, size_t size, const char *format, .
#pragma warning( disable : 4996 ) ..) = &snprintf;
#endif #endif
}
/** stringstream deals with locale so this is a lot faster than std::st ringstream for UTF8 */ /** stringstream deals with locale so this is a lot faster than std::st ringstream for UTF8 */
class StringBuilder { class StringBuilder {
public: public:
static const size_t MONGO_DBL_SIZE = 3 + DBL_MANT_DIG - DBL_MIN_EXP
;
static const size_t MONGO_S32_SIZE = 12;
static const size_t MONGO_U32_SIZE = 11;
static const size_t MONGO_S64_SIZE = 23;
static const size_t MONGO_U64_SIZE = 22;
static const size_t MONGO_S16_SIZE = 7;
StringBuilder( int initsize=256 ) StringBuilder( int initsize=256 )
: _buf( initsize ) { : _buf( initsize ) {
} }
StringBuilder& operator<<( double x ) { StringBuilder& operator<<( double x ) {
return SBNUM( x , 25 , "%g" ); return SBNUM( x , MONGO_DBL_SIZE , "%g" );
} }
StringBuilder& operator<<( int x ) { StringBuilder& operator<<( int x ) {
return SBNUM( x , 11 , "%d" ); return SBNUM( x , MONGO_S32_SIZE , "%d" );
} }
StringBuilder& operator<<( unsigned x ) { StringBuilder& operator<<( unsigned x ) {
return SBNUM( x , 11 , "%u" ); return SBNUM( x , MONGO_U32_SIZE , "%u" );
} }
StringBuilder& operator<<( long x ) { StringBuilder& operator<<( long x ) {
return SBNUM( x , 22 , "%ld" ); return SBNUM( x , MONGO_S64_SIZE , "%ld" );
} }
StringBuilder& operator<<( unsigned long x ) { StringBuilder& operator<<( unsigned long x ) {
return SBNUM( x , 22 , "%lu" ); return SBNUM( x , MONGO_U64_SIZE , "%lu" );
} }
StringBuilder& operator<<( long long x ) { StringBuilder& operator<<( long long x ) {
return SBNUM( x , 22 , "%lld" ); return SBNUM( x , MONGO_S64_SIZE , "%lld" );
} }
StringBuilder& operator<<( unsigned long long x ) { StringBuilder& operator<<( unsigned long long x ) {
return SBNUM( x , 22 , "%llu" ); return SBNUM( x , MONGO_U64_SIZE , "%llu" );
} }
StringBuilder& operator<<( short x ) { StringBuilder& operator<<( short x ) {
return SBNUM( x , 8 , "%hd" ); return SBNUM( x , MONGO_S16_SIZE , "%hd" );
} }
StringBuilder& operator<<( char c ) { StringBuilder& operator<<( char c ) {
_buf.grow( 1 )[0] = c; _buf.grow( 1 )[0] = c;
return *this; return *this;
} }
void appendDoubleNice( double x ) { void appendDoubleNice( double x ) {
int prev = _buf.l; const int prev = _buf.l;
char * start = _buf.grow( 32 ); const int maxSize = 32;
int z = sprintf( start , "%.16g" , x ); char * start = _buf.grow( maxSize );
int z = mongo_snprintf( start , maxSize , "%.16g" , x );
assert( z >= 0 ); assert( z >= 0 );
assert( z < maxSize );
_buf.l = prev + z; _buf.l = prev + z;
if( strchr(start, '.') == 0 && strchr(start, 'E') == 0 && strch r(start, 'N') == 0 ) { if( strchr(start, '.') == 0 && strchr(start, 'E') == 0 && strch r(start, 'N') == 0 ) {
write( ".0" , 2 ); write( ".0" , 2 );
} }
} }
void write( const char* buf, int len) { memcpy( _buf.grow( len ) , buf , len ); } void write( const char* buf, int len) { memcpy( _buf.grow( len ) , buf , len ); }
void append( const StringData& str ) { memcpy( _buf.grow( str.size( ) ) , str.data() , str.size() ); } void append( const StringData& str ) { memcpy( _buf.grow( str.size( ) ) , str.data() , str.size() ); }
skipping to change at line 311 skipping to change at line 323
private: private:
BufBuilder _buf; BufBuilder _buf;
// non-copyable, non-assignable // non-copyable, non-assignable
StringBuilder( const StringBuilder& ); StringBuilder( const StringBuilder& );
StringBuilder& operator=( const StringBuilder& ); StringBuilder& operator=( const StringBuilder& );
template <typename T> template <typename T>
StringBuilder& SBNUM(T val,int maxSize,const char *macro) { StringBuilder& SBNUM(T val,int maxSize,const char *macro) {
int prev = _buf.l; int prev = _buf.l;
int z = sprintf( _buf.grow(maxSize) , macro , (val) ); int z = mongo_snprintf( _buf.grow(maxSize) , maxSize , macro , (val) );
assert( z >= 0 ); assert( z >= 0 );
assert( z < maxSize );
_buf.l = prev + z; _buf.l = prev + z;
return *this; return *this;
} }
}; };
#if defined(_WIN32)
#pragma warning( pop )
#endif
} // namespace mongo } // namespace mongo
 End of changes. 19 change blocks. 
22 lines changed or deleted 32 lines changed or added


 dbclient_rs.h   dbclient_rs.h 
skipping to change at line 121 skipping to change at line 121
* *
* @param checkAllSecondaries if set to false, stop immediately whe n * @param checkAllSecondaries if set to false, stop immediately whe n
* the master is found or when _master is not -1. * 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( const string& hostAddr );
/** /**
* 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);
/** /**
skipping to change at line 182 skipping to change at line 182
* the reply from the connection the lock holder got is the actual response * the reply from the connection the lock holder got is the actual response
* to what it sent. * to what it sent.
* *
* Deadlock WARNING: never acquire this while holding _lock * 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( c != NULL ),
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. 3 change blocks. 
3 lines changed or deleted 2 lines changed or added


 queryoptimizer.h   queryoptimizer.h 
skipping to change at line 317 skipping to change at line 317
private: private:
void addOtherPlans( bool checkFirst ); void addOtherPlans( bool checkFirst );
void addPlan( QueryPlanPtr plan, bool checkFirst ) { void addPlan( QueryPlanPtr plan, bool checkFirst ) {
if ( checkFirst && plan->indexKey().woCompare( _plans[ 0 ]->ind exKey() ) == 0 ) if ( checkFirst && plan->indexKey().woCompare( _plans[ 0 ]->ind exKey() ) == 0 )
return; return;
_plans.push_back( plan ); _plans.push_back( plan );
} }
void init(); void init();
void addHint( IndexDetails &id ); void addHint( IndexDetails &id );
void warnOnCappedIdTableScan() const;
class Runner { class Runner {
public: public:
Runner( QueryPlanSet &plans, QueryOp &op ); Runner( QueryPlanSet &plans, QueryOp &op );
/** /**
* Iterate interactively through candidate documents on all pla ns. * Iterate interactively through candidate documents on all pla ns.
* QueryOp objects are returned at each interleaved step. * QueryOp objects are returned at each interleaved step.
*/ */
/** @return a plan that has completed, otherwise an arbitrary p lan. */ /** @return a plan that has completed, otherwise an arbitrary p lan. */
 End of changes. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 security_common.h   security_common.h 
skipping to change at line 64 skipping to change at line 64
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 NONE; } 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);
void authenticate(const string& dbname, const string& user, const b ool readOnly);
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);
}; };
extern CmdAuthenticate cmdAuthenticate;
class CmdLogout : public Command { class CmdLogout : public Command {
public: public:
virtual bool logTheOp() { virtual bool logTheOp() {
return false; return false;
} }
virtual bool slaveOk() const { virtual bool slaveOk() const {
return true; return true;
} }
void help(stringstream& h) const { h << "de-authenticate"; } void help(stringstream& h) const { h << "de-authenticate"; }
virtual LockType locktype() const { return NONE; } virtual LockType locktype() const { return NONE; }
 End of changes. 3 change blocks. 
1 lines changed or deleted 3 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/