summaryrefslogtreecommitdiff
path: root/src/mongo/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/util')
-rw-r--r--src/mongo/util/alignedbuilder.cpp14
-rw-r--r--src/mongo/util/alignedbuilder.h2
-rw-r--r--src/mongo/util/array.h4
-rw-r--r--src/mongo/util/assert_util.cpp6
-rw-r--r--src/mongo/util/assert_util.h14
-rw-r--r--src/mongo/util/background.cpp2
-rw-r--r--src/mongo/util/base64.h4
-rw-r--r--src/mongo/util/bufreader.h2
-rw-r--r--src/mongo/util/concurrency/list.h2
-rw-r--r--src/mongo/util/concurrency/mutex.h15
-rw-r--r--src/mongo/util/concurrency/mutexdebugger.h8
-rw-r--r--src/mongo/util/concurrency/qlock.h14
-rw-r--r--src/mongo/util/concurrency/rwlock.h8
-rw-r--r--src/mongo/util/concurrency/rwlockimpl.h4
-rw-r--r--src/mongo/util/concurrency/synchronization.cpp2
-rw-r--r--src/mongo/util/concurrency/task.cpp2
-rw-r--r--src/mongo/util/concurrency/thread_pool.cpp8
-rw-r--r--src/mongo/util/concurrency/thread_pool.h2
-rw-r--r--src/mongo/util/debug_util.cpp2
-rw-r--r--src/mongo/util/file.h6
-rw-r--r--src/mongo/util/file_allocator.cpp2
-rw-r--r--src/mongo/util/goodies.h7
-rw-r--r--src/mongo/util/hashtab.h4
-rw-r--r--src/mongo/util/hex.h2
-rw-r--r--src/mongo/util/log.cpp10
-rw-r--r--src/mongo/util/logfile.cpp24
-rw-r--r--src/mongo/util/lruishmap.h2
-rwxr-xr-xsrc/mongo/util/mmap.cpp4
-rw-r--r--src/mongo/util/mmap.h8
-rw-r--r--src/mongo/util/mmap_mm.cpp2
-rw-r--r--src/mongo/util/mmap_posix.cpp4
-rw-r--r--src/mongo/util/mmap_win.cpp6
-rw-r--r--src/mongo/util/mongoutils/test.cpp10
-rw-r--r--src/mongo/util/net/hostandport.h10
-rw-r--r--src/mongo/util/net/httpclient.cpp2
-rw-r--r--src/mongo/util/net/listen.cpp4
-rw-r--r--src/mongo/util/net/message.cpp2
-rw-r--r--src/mongo/util/net/message.h22
-rw-r--r--src/mongo/util/net/message_port.cpp10
-rw-r--r--src/mongo/util/net/message_server_asio.cpp6
-rw-r--r--src/mongo/util/net/message_server_port.cpp4
-rw-r--r--src/mongo/util/net/miniwebserver.cpp2
-rw-r--r--src/mongo/util/net/sock.cpp16
-rw-r--r--src/mongo/util/processinfo_none.cpp2
-rwxr-xr-xsrc/mongo/util/processinfo_win32.cpp6
-rw-r--r--src/mongo/util/ramlog.cpp2
-rw-r--r--src/mongo/util/text.cpp6
-rw-r--r--src/mongo/util/time_support.h8
-rwxr-xr-xsrc/mongo/util/trace.cpp2
-rw-r--r--src/mongo/util/util.cpp30
-rw-r--r--src/mongo/util/version.cpp46
51 files changed, 186 insertions, 200 deletions
diff --git a/src/mongo/util/alignedbuilder.cpp b/src/mongo/util/alignedbuilder.cpp
index b2e0461b733..c17ed55922b 100644
--- a/src/mongo/util/alignedbuilder.cpp
+++ b/src/mongo/util/alignedbuilder.cpp
@@ -59,15 +59,15 @@ namespace mongo {
}
void AlignedBuilder::mallocSelfAligned(unsigned sz) {
- assert( sz == _p._size );
+ verify( sz == _p._size );
void *p = malloc(sz + Alignment - 1);
_p._allocationAddress = p;
size_t s = (size_t) p;
size_t sold = s;
s += Alignment - 1;
s = (s/Alignment)*Alignment;
- assert( s >= sold ); // begining
- assert( (s + sz) <= (sold + sz + Alignment - 1) ); //end
+ verify( s >= sold ); // begining
+ verify( (s + sz) <= (sold + sz + Alignment - 1) ); //end
_p._data = (char *) s;
}
@@ -75,7 +75,7 @@ namespace mongo {
void NOINLINE_DECL AlignedBuilder::growReallocate(unsigned oldLen) {
dassert( _len > _p._size );
unsigned a = _p._size;
- assert( a );
+ verify( a );
while( 1 ) {
if( a < 128 * 1024 * 1024 )
a *= 2;
@@ -88,7 +88,7 @@ namespace mongo {
abort();
}
wassert( a <= 256*1024*1024 );
- assert( a <= 512*1024*1024 );
+ verify( a <= 512*1024*1024 );
if( _len < a )
break;
}
@@ -111,7 +111,7 @@ namespace mongo {
_p._data = (char *) p;
#else
mallocSelfAligned(sz);
- assert( ((size_t) _p._data) % Alignment == 0 );
+ verify( ((size_t) _p._data) % Alignment == 0 );
#endif
}
@@ -119,7 +119,7 @@ namespace mongo {
// posix_memalign alignment is not maintained on reallocs, so we can't use realloc().
AllocationInfo old = _p;
_malloc(newSize);
- assert( oldLen <= _len );
+ verify( oldLen <= _len );
memcpy(_p._data, old._data, oldLen);
_free(old._allocationAddress);
}
diff --git a/src/mongo/util/alignedbuilder.h b/src/mongo/util/alignedbuilder.h
index 1d246a9d78e..d55378cf2b9 100644
--- a/src/mongo/util/alignedbuilder.h
+++ b/src/mongo/util/alignedbuilder.h
@@ -87,7 +87,7 @@ namespace mongo {
void appendStr(const StringData &str , bool includeEOO = true ) {
const unsigned len = str.size() + ( includeEOO ? 1 : 0 );
- assert( len < (unsigned) BSONObjMaxUserSize );
+ verify( len < (unsigned) BSONObjMaxUserSize );
memcpy(grow(len), str.data(), len);
}
diff --git a/src/mongo/util/array.h b/src/mongo/util/array.h
index 12822252fd7..c765e8799b9 100644
--- a/src/mongo/util/array.h
+++ b/src/mongo/util/array.h
@@ -41,7 +41,7 @@ namespace mongo {
}
T& operator[]( int x ) {
- assert( x >= 0 && x < _capacity );
+ verify( x >= 0 && x < _capacity );
return _data[x];
}
@@ -50,7 +50,7 @@ namespace mongo {
}
void push_back( const T& t ) {
- assert( _size < _capacity );
+ verify( _size < _capacity );
_data[_size++] = t;
}
diff --git a/src/mongo/util/assert_util.cpp b/src/mongo/util/assert_util.cpp
index 8e6eb693a09..72adf1f913e 100644
--- a/src/mongo/util/assert_util.cpp
+++ b/src/mongo/util/assert_util.cpp
@@ -112,7 +112,7 @@ namespace mongo {
breakpoint();
#if defined(_DEBUG) || defined(_DURABLEDEFAULTON) || defined(_DURABLEDEFAULTOFF)
// this is so we notice in buildbot
- log() << "\n\n***aborting after assert() failure as this is a debug/test build\n\n" << endl;
+ log() << "\n\n***aborting after verify() failure as this is a debug/test build\n\n" << endl;
abort();
#endif
throw e;
@@ -219,7 +219,7 @@ namespace mongo {
NOINLINE_DECL ErrorMsg::ErrorMsg(const char *msg, char ch) {
int l = strlen(msg);
- assert( l < 128);
+ verify( l < 128);
memcpy(buf, msg, l);
char *p = buf + l;
p[0] = ch;
@@ -228,7 +228,7 @@ namespace mongo {
NOINLINE_DECL ErrorMsg::ErrorMsg(const char *msg, unsigned val) {
int l = strlen(msg);
- assert( l < 128);
+ verify( l < 128);
memcpy(buf, msg, l);
char *p = buf + l;
sprintf(p, "%u", val);
diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h
index aac5c3dbcc5..d46df42d934 100644
--- a/src/mongo/util/assert_util.h
+++ b/src/mongo/util/assert_util.h
@@ -18,6 +18,7 @@
#pragma once
#include "../bson/inline_decls.h"
+#include <typeinfo>
// MONGO_NORETURN undefed at end of file
#ifdef __GNUC__
@@ -152,7 +153,6 @@ namespace mongo {
void asserted(const char *msg, const char *file, unsigned line) MONGO_NORETURN;
void wasserted(const char *msg, const char *file, unsigned line);
- void verifyFailed( int msgid );
void fassertFailed( int msgid );
/** a "user assertion". throws UserAssertion. logs. typically used for errors that a user
@@ -178,18 +178,12 @@ namespace mongo {
inline std::string causedBy( const std::exception& e ){ return causedBy( e.what() ); }
inline std::string causedBy( const std::string& e ){ return causedBy( e.c_str() ); }
- /** 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 ) verifyFailed( msgid ); }
-
/** abends on condition failure */
inline void fassert( int msgid , bool testOK ) { if ( ! testOK ) fassertFailed( msgid ); }
-#ifdef assert
-#undef assert
-#endif
-#define MONGO_assert(_Expression) (void)( MONGO_likely(!!(_Expression)) || (mongo::asserted(#_Expression, __FILE__, __LINE__), 0) )
-#define assert MONGO_assert
+#define MONGO_verify(_Expression) (void)( MONGO_likely(!!(_Expression)) || (mongo::asserted(#_Expression, __FILE__, __LINE__), 0) )
+#define verify MONGO_verify
/* "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) )
@@ -211,7 +205,7 @@ namespace mongo {
could be slow.
*/
#if defined(_DEBUG)
-# define MONGO_dassert assert
+# define MONGO_dassert verify
#else
# define MONGO_dassert(x)
#endif
diff --git a/src/mongo/util/background.cpp b/src/mongo/util/background.cpp
index ef3ee9426b9..50ade692e09 100644
--- a/src/mongo/util/background.cpp
+++ b/src/mongo/util/background.cpp
@@ -83,7 +83,7 @@ namespace mongo {
}
bool BackgroundJob::wait( unsigned msTimeOut ) {
- assert( !_status->deleteSelf ); // you cannot call wait on a self-deleting job
+ verify( !_status->deleteSelf ); // you cannot call wait on a self-deleting job
scoped_lock l( _status->m );
while ( _status->state != Done ) {
if ( msTimeOut ) {
diff --git a/src/mongo/util/base64.h b/src/mongo/util/base64.h
index 505b5d78cca..d5507bf0932 100644
--- a/src/mongo/util/base64.h
+++ b/src/mongo/util/base64.h
@@ -37,9 +37,9 @@ namespace mongo {
test();
}
void test() {
- assert( strlen( (char*)encode ) == 64 );
+ verify( strlen( (char*)encode ) == 64 );
for ( int i=0; i<26; i++ )
- assert( encode[i] == toupper( encode[i+26] ) );
+ verify( encode[i] == toupper( encode[i+26] ) );
}
char e( int x ) {
diff --git a/src/mongo/util/bufreader.h b/src/mongo/util/bufreader.h
index 58257ce011d..4cb34f483ab 100644
--- a/src/mongo/util/bufreader.h
+++ b/src/mongo/util/bufreader.h
@@ -64,7 +64,7 @@ namespace mongo {
/** back up by nbytes */
void rewind(unsigned nbytes) {
_pos = ((char *) _pos) - nbytes;
- assert( _pos >= _start );
+ verify( _pos >= _start );
}
/** return current position pointer, and advance by len */
diff --git a/src/mongo/util/concurrency/list.h b/src/mongo/util/concurrency/list.h
index 61bdd55f46f..c19fcea1f22 100644
--- a/src/mongo/util/concurrency/list.h
+++ b/src/mongo/util/concurrency/list.h
@@ -63,7 +63,7 @@ namespace mongo {
T* head() const { return (T*) _head; }
void push(T* t) {
- assert( t->_next == 0 );
+ verify( t->_next == 0 );
scoped_lock lk(_m);
t->_next = (T*) _head;
_head = t;
diff --git a/src/mongo/util/concurrency/mutex.h b/src/mongo/util/concurrency/mutex.h
index d3a7518e5bc..4ae6c78c9c6 100644
--- a/src/mongo/util/concurrency/mutex.h
+++ b/src/mongo/util/concurrency/mutex.h
@@ -22,6 +22,7 @@
#if defined(_DEBUG)
#include "mutexdebugger.h"
#endif
+#include "mongo/util/assert_util.h"
namespace mongo {
@@ -130,12 +131,12 @@ namespace mongo {
void lock() {
EnterCriticalSection(&_cs);
#if defined(_DEBUG)
- assert( _cs.RecursionCount == 1 );
+ verify( _cs.RecursionCount == 1 );
#endif
}
void dassertLocked() const {
#if defined(_DEBUG)
- assert( _cs.OwningThread == (HANDLE) GetCurrentThreadId() );
+ verify( _cs.OwningThread == (HANDLE) GetCurrentThreadId() );
#endif
}
void unlock() {
@@ -155,15 +156,15 @@ namespace mongo {
class SimpleMutex : boost::noncopyable {
public:
void dassertLocked() const { }
- SimpleMutex(const char* name) { assert( pthread_mutex_init(&_lock,0) == 0 ); }
+ SimpleMutex(const char* name) { verify( pthread_mutex_init(&_lock,0) == 0 ); }
~SimpleMutex(){
if ( ! StaticObserver::_destroyingStatics ) {
- assert( pthread_mutex_destroy(&_lock) == 0 );
+ verify( pthread_mutex_destroy(&_lock) == 0 );
}
}
- void lock() { assert( pthread_mutex_lock(&_lock) == 0 ); }
- void unlock() { assert( pthread_mutex_unlock(&_lock) == 0 ); }
+ void lock() { verify( pthread_mutex_lock(&_lock) == 0 ); }
+ void unlock() { verify( pthread_mutex_unlock(&_lock) == 0 ); }
public:
class scoped_lock : boost::noncopyable {
SimpleMutex& _m;
@@ -195,7 +196,7 @@ namespace mongo {
rm.m.lock();
}
~scoped_lock() {
- assert( nLocksByMe > 0 );
+ verify( nLocksByMe > 0 );
if( --nLocksByMe == 0 ) {
rm.m.unlock();
}
diff --git a/src/mongo/util/concurrency/mutexdebugger.h b/src/mongo/util/concurrency/mutexdebugger.h
index 6347d50171b..8c41a687490 100644
--- a/src/mongo/util/concurrency/mutexdebugger.h
+++ b/src/mongo/util/concurrency/mutexdebugger.h
@@ -46,7 +46,7 @@ namespace mongo {
void entering(mid m) {
if( this == 0 || m == 0 ) return;
- assert( magic == 0x12345678 );
+ verify( magic == 0x12345678 );
Preceeding *_preceeding = us.get();
if( _preceeding == 0 )
@@ -57,7 +57,7 @@ namespace mongo {
aBreakPoint();
if( preceeding[b.c_str()] ) {
cout << "****** MutexDebugger error! warning " << b << " was locked before " << a << endl;
- assert(false);
+ verify(false);
}
}
@@ -101,7 +101,7 @@ namespace mongo {
}
if( failed ) {
cout << err << endl;
- assert( 0 );
+ verify( 0 );
}
}
void leaving(mid m) {
@@ -110,7 +110,7 @@ namespace mongo {
preceeding[m]--;
if( preceeding[m] < 0 ) {
cout << "ERROR: lock count for " << m << " is " << preceeding[m] << endl;
- assert( preceeding[m] >= 0 );
+ verify( preceeding[m] >= 0 );
}
}
};
diff --git a/src/mongo/util/concurrency/qlock.h b/src/mongo/util/concurrency/qlock.h
index a87cfd25f2b..781b5dd35f3 100644
--- a/src/mongo/util/concurrency/qlock.h
+++ b/src/mongo/util/concurrency/qlock.h
@@ -82,13 +82,13 @@ namespace mongo {
case 'R' : return them == 'W' || them == 'w';
case 'w' : return them == 'W' || them == 'R';
case 'r' : return them == 'W';
- default : assert(false);
+ default : verify(false);
}
return false;
}
inline void QLock::notifyWeUnlocked(char me) {
- assert( W.n == 0 );
+ verify( W.n == 0 );
if( U.n ) {
// U is highest priority
if( r.n + w.n + W.n == 0 )
@@ -203,9 +203,9 @@ namespace mongo {
// downgrade from W state to R state
inline void QLock::W_to_R() {
boost::mutex::scoped_lock lk(m);
- assert( W.n == 1 );
- assert( R.n == 0 );
- assert( U.n == 0 );
+ verify( W.n == 1 );
+ verify( R.n == 0 );
+ verify( U.n == 0 );
W.n = 0;
R.n = 1;
notifyWeUnlocked('W');
@@ -216,7 +216,7 @@ namespace mongo {
// if two threads try to do this you will deadlock.
inline bool QLock::R_to_W() {
boost::mutex::scoped_lock lk(m);
- assert( R.n > 0 && W.n == 0 );
+ verify( R.n > 0 && W.n == 0 );
U.n++;
fassert( 16136, U.n == 1 ); // for now we only allow one upgrade attempter
int pass = 0;
@@ -230,7 +230,7 @@ namespace mongo {
R.n--;
W.n++;
U.n--;
- assert( R.n == 0 && W.n == 1 && U.n == 0 );
+ verify( R.n == 0 && W.n == 1 && U.n == 0 );
return true;
}
diff --git a/src/mongo/util/concurrency/rwlock.h b/src/mongo/util/concurrency/rwlock.h
index 076297ba791..38bb8105845 100644
--- a/src/mongo/util/concurrency/rwlock.h
+++ b/src/mongo/util/concurrency/rwlock.h
@@ -57,7 +57,7 @@ namespace mongo {
}
public:
void upgrade() { // upgradable -> exclusive lock
- assert( x == UpgradableState );
+ verify( x == UpgradableState );
RWLockBase::upgrade();
x = Exclusive;
}
@@ -83,7 +83,7 @@ namespace mongo {
public:
Upgradable(RWLock& r) : _r(r) {
r.lockAsUpgradable();
- assert( _r.x == NilState );
+ verify( _r.x == NilState );
_r.x = RWLock::UpgradableState;
}
~Upgradable() {
@@ -92,7 +92,7 @@ namespace mongo {
_r.unlockFromUpgradable();
}
else {
- //TEMP assert( _r.x == Exclusive ); // has been upgraded
+ //TEMP verify( _r.x == Exclusive ); // has been upgraded
_r.x = NilState;
_r.unlock();
}
@@ -164,7 +164,7 @@ namespace mongo {
RWLockRecursive(const char *name) : _name(name) { }
void assertExclusivelyLocked() {
- assert( _state.get() < 0 );
+ verify( _state.get() < 0 );
}
class Exclusive : boost::noncopyable {
diff --git a/src/mongo/util/concurrency/rwlockimpl.h b/src/mongo/util/concurrency/rwlockimpl.h
index 0144a24cad9..440b778eedd 100644
--- a/src/mongo/util/concurrency/rwlockimpl.h
+++ b/src/mongo/util/concurrency/rwlockimpl.h
@@ -83,7 +83,7 @@ namespace mongo {
friend class SimpleRWLock;
pthread_rwlock_t _lock;
static void check( int x ) {
- assert( x == 0 );
+ verify( x == 0 );
}
protected:
~RWLockBase() {
@@ -137,8 +137,6 @@ namespace mongo { typedef boost::modified_shared_mutex shared_mutex; }
# include <boost/thread/shared_mutex.hpp>
namespace mongo { using boost::shared_mutex; }
# endif
-# undef assert
-# define assert MONGO_assert
namespace mongo {
class RWLockBase : boost::noncopyable {
diff --git a/src/mongo/util/concurrency/synchronization.cpp b/src/mongo/util/concurrency/synchronization.cpp
index ff4e8047f84..0ad0519812e 100644
--- a/src/mongo/util/concurrency/synchronization.cpp
+++ b/src/mongo/util/concurrency/synchronization.cpp
@@ -34,7 +34,7 @@ namespace mongo {
void Notification::notifyOne() {
scoped_lock lock( _mutex );
- assert( cur != lookFor );
+ verify( cur != lookFor );
cur++;
_condition.notify_one();
}
diff --git a/src/mongo/util/concurrency/task.cpp b/src/mongo/util/concurrency/task.cpp
index 43ce340021b..786c93b4efd 100644
--- a/src/mongo/util/concurrency/task.cpp
+++ b/src/mongo/util/concurrency/task.cpp
@@ -46,7 +46,7 @@ namespace mongo {
void Task::halt() { repeat = 0; }
void Task::run() {
- assert( n == 0 );
+ verify( n == 0 );
while( 1 ) {
n++;
try {
diff --git a/src/mongo/util/concurrency/thread_pool.cpp b/src/mongo/util/concurrency/thread_pool.cpp
index 1c258847cb5..b64a904cd4a 100644
--- a/src/mongo/util/concurrency/thread_pool.cpp
+++ b/src/mongo/util/concurrency/thread_pool.cpp
@@ -40,8 +40,8 @@ namespace mongo {
}
void set_task(Task& func) {
- assert(!func.empty());
- assert(_is_done);
+ verify(!func.empty());
+ verify(_is_done);
_is_done = false;
_task.put(func);
@@ -87,10 +87,10 @@ namespace mongo {
ThreadPool::~ThreadPool() {
join();
- assert(_tasks.empty());
+ verify(_tasks.empty());
// O(n) but n should be small
- assert(_freeWorkers.size() == (unsigned)_nThreads);
+ verify(_freeWorkers.size() == (unsigned)_nThreads);
while(!_freeWorkers.empty()) {
delete _freeWorkers.front();
diff --git a/src/mongo/util/concurrency/thread_pool.h b/src/mongo/util/concurrency/thread_pool.h
index b348ed1d01b..ea2f801b63c 100644
--- a/src/mongo/util/concurrency/thread_pool.h
+++ b/src/mongo/util/concurrency/thread_pool.h
@@ -19,8 +19,6 @@
#include <boost/function.hpp>
#include <boost/bind.hpp>
-#undef assert
-#define assert MONGO_assert
namespace mongo {
diff --git a/src/mongo/util/debug_util.cpp b/src/mongo/util/debug_util.cpp
index 8ba6534ef7c..3c4489c9a1c 100644
--- a/src/mongo/util/debug_util.cpp
+++ b/src/mongo/util/debug_util.cpp
@@ -51,7 +51,7 @@ namespace mongo {
}
void setupSIGTRAPforGDB() {
- assert( signal(SIGTRAP , launchGDB ) != SIG_ERR );
+ verify( signal(SIGTRAP , launchGDB ) != SIG_ERR );
}
#else
void setupSIGTRAPforGDB() {
diff --git a/src/mongo/util/file.h b/src/mongo/util/file.h
index 368e6927b43..410c20d3651 100644
--- a/src/mongo/util/file.h
+++ b/src/mongo/util/file.h
@@ -45,13 +45,13 @@ namespace mongo {
bool bad() {return false;}
bool is_open() {return false;}
fileofs len() { return 0; }
- void fsync() { assert(false); }
+ void fsync() { verify(false); }
// shrink file to size bytes. No-op if file already smaller.
void truncate(fileofs size);
/** @return -1 if error or unavailable */
- static boost::intmax_t freeSpace(const string &path) { assert(false); return -1; }
+ static boost::intmax_t freeSpace(const string &path) { verify(false); return -1; }
};
#if defined(_WIN32)
@@ -210,7 +210,7 @@ namespace mongo {
void fsync() { ::fsync(fd); }
static boost::intmax_t freeSpace ( const string &path ) {
struct statvfs info;
- assert( !statvfs( path.c_str() , &info ) );
+ verify( !statvfs( path.c_str() , &info ) );
return boost::intmax_t( info.f_bavail ) * info.f_frsize;
}
diff --git a/src/mongo/util/file_allocator.cpp b/src/mongo/util/file_allocator.cpp
index 6a1744398c5..cb470f82446 100644
--- a/src/mongo/util/file_allocator.cpp
+++ b/src/mongo/util/file_allocator.cpp
@@ -52,7 +52,7 @@ namespace mongo {
flushMyDirectory(parent); // flushes grandparent to ensure parent exists after crash
}
- assert(boost::filesystem::is_directory(parent));
+ verify(boost::filesystem::is_directory(parent));
return parent;
}
diff --git a/src/mongo/util/goodies.h b/src/mongo/util/goodies.h
index c2ca29a24e5..6683ee189f9 100644
--- a/src/mongo/util/goodies.h
+++ b/src/mongo/util/goodies.h
@@ -18,8 +18,8 @@
#pragma once
-#include "../bson/util/misc.h"
#include "concurrency/mutex.h"
+#include "../bson/util/misc.h"
namespace mongo {
@@ -112,9 +112,6 @@ namespace mongo {
#define MONGO_FLOG log() << __FILE__ ":" << __LINE__ << endl
#define FLOG MONGO_FLOG
-#undef assert
-#define assert MONGO_assert
-
inline bool startsWith(const char *str, const char *prefix) {
size_t l = strlen(prefix);
if ( strlen(str) < l ) return false;
@@ -150,7 +147,7 @@ namespace mongo {
#if !defined(_WIN32)
typedef int HANDLE;
inline void strcpy_s(char *dst, unsigned len, const char *src) {
- assert( strlen(src) < len );
+ verify( strlen(src) < len );
strcpy(dst, src);
}
#else
diff --git a/src/mongo/util/hashtab.h b/src/mongo/util/hashtab.h
index f1a33068e07..19253d7c60d 100644
--- a/src/mongo/util/hashtab.h
+++ b/src/mongo/util/hashtab.h
@@ -111,7 +111,7 @@ namespace mongo {
if ( sizeof(Node) != 628 ) {
out() << "HashTable() " << _name << " sizeof(node):" << sizeof(Node) << " n:" << n << " sizeof(Key): " << sizeof(Key) << " sizeof(Type):" << sizeof(Type) << endl;
- assert( sizeof(Node) == 628 );
+ verify( sizeof(Node) == 628 );
}
}
@@ -147,7 +147,7 @@ namespace mongo {
n->hash = k.hash();
}
else {
- assert( n->hash == k.hash() );
+ verify( n->hash == k.hash() );
}
n->value = value;
return true;
diff --git a/src/mongo/util/hex.h b/src/mongo/util/hex.h
index 8cf30f2d9d3..54eb8de8102 100644
--- a/src/mongo/util/hex.h
+++ b/src/mongo/util/hex.h
@@ -26,7 +26,7 @@ namespace mongo {
return c - 'a' + 10;
if ( 'A' <= c && c <= 'F' )
return c - 'A' + 10;
- assert( false );
+ verify( false );
return 0xff;
}
inline char fromHex( const char *c ) {
diff --git a/src/mongo/util/log.cpp b/src/mongo/util/log.cpp
index 1f05eaee3b5..dd4a24223ca 100644
--- a/src/mongo/util/log.cpp
+++ b/src/mongo/util/log.cpp
@@ -62,7 +62,7 @@ namespace mongo {
cout << "logpath [" << lp << "] should be a filename, not a directory" << endl;
dbexit( EXIT_BADOPTIONS );
- assert( 0 );
+ verify( 0 );
}
if ( ! append ) {
@@ -78,7 +78,7 @@ namespace mongo {
cout << "log file [" << lp << "] exists and couldn't make backup; run with --logappend or manually remove file (" << strerror(errno) << ")" << endl;
dbexit( EXIT_BADOPTIONS );
- assert( 0 );
+ verify( 0 );
}
}
}
@@ -88,7 +88,7 @@ namespace mongo {
if ( ! test ) {
cout << "can't open [" << lp << "] for log file: " << errnoWithDescription() << endl;
dbexit( EXIT_BADOPTIONS );
- assert( 0 );
+ verify( 0 );
}
if (append && exists){
@@ -150,7 +150,7 @@ namespace mongo {
if ( !tmp ) {
cerr << "can't open: " << _path.c_str() << " for log file" << endl;
dbexit( EXIT_BADOPTIONS );
- assert( 0 );
+ verify( 0 );
}
// redirect stdout and stderr to log file
@@ -334,7 +334,7 @@ namespace mongo {
}
string out( b.buf() , b.len() - 1);
- assert( b.len() < spaceNeeded );
+ verify( b.len() < spaceNeeded );
scoped_lock lk(mutex);
diff --git a/src/mongo/util/logfile.cpp b/src/mongo/util/logfile.cpp
index 22da9607ed6..d6992465936 100644
--- a/src/mongo/util/logfile.cpp
+++ b/src/mongo/util/logfile.cpp
@@ -78,7 +78,7 @@ namespace mongo {
}
void LogFile::truncate() {
- assert(_fd != INVALID_HANDLE_VALUE);
+ verify(_fd != INVALID_HANDLE_VALUE);
if (!SetEndOfFile(_fd)){
msgasserted(15871, "Couldn't truncate file: " + errnoWithDescription());
@@ -91,7 +91,7 @@ namespace mongo {
memset(&o,0,sizeof(o));
(unsigned long long&) o.Offset = offset;
BOOL ok= WriteFile(_fd, _buf, _len, 0, &o);
- assert(ok);
+ verify(ok);
}
void LogFile::readAt(unsigned long long offset, void *_buf, size_t _len) {
@@ -105,14 +105,14 @@ namespace mongo {
string e = errnoWithDescription();
//DWORD e = GetLastError();
log() << "LogFile readAt(" << offset << ") len:" << _len << "errno:" << e << endl;
- assert(false);
+ verify(false);
}
}
void LogFile::synchronousAppend(const void *_buf, size_t _len) {
const size_t BlockSize = 8 * 1024 * 1024;
- assert(_fd);
- assert(_len % 4096 == 0);
+ verify(_fd);
+ verify(_len % 4096 == 0);
const char *buf = (const char *) _buf;
size_t left = _len;
while( left ) {
@@ -184,7 +184,7 @@ namespace mongo {
}
void LogFile::truncate() {
- assert(_fd >= 0);
+ verify(_fd >= 0);
BOOST_STATIC_ASSERT(sizeof(off_t) == 8); // we don't want overflow here
const off_t pos = lseek(_fd, 0, SEEK_CUR); // doesn't actually seek
@@ -196,7 +196,7 @@ namespace mongo {
}
void LogFile::writeAt(unsigned long long offset, const void *buf, size_t len) {
- assert(((size_t)buf)%4096==0); // aligned
+ verify(((size_t)buf)%4096==0); // aligned
ssize_t written = pwrite(_fd, buf, len, offset);
if( written != (ssize_t) len ) {
log() << "writeAt fails " << errnoWithDescription() << endl;
@@ -209,9 +209,9 @@ namespace mongo {
}
void LogFile::readAt(unsigned long long offset, void *_buf, size_t _len) {
- assert(((size_t)_buf)%4096==0); // aligned
+ verify(((size_t)_buf)%4096==0); // aligned
ssize_t rd = pread(_fd, _buf, _len, offset);
- assert( rd != -1 );
+ verify( rd != -1 );
}
void LogFile::synchronousAppend(const void *b, size_t len) {
@@ -220,11 +220,11 @@ namespace mongo {
#endif
const char *buf = (char *) b;
- assert(_fd);
- assert(((size_t)buf)%4096==0); // aligned
+ verify(_fd);
+ verify(((size_t)buf)%4096==0); // aligned
if( len % 4096 != 0 ) {
log() << len << ' ' << len % 4096 << endl;
- assert(false);
+ verify(false);
}
ssize_t written = write(_fd, buf, len);
if( written != (ssize_t) len ) {
diff --git a/src/mongo/util/lruishmap.h b/src/mongo/util/lruishmap.h
index ba91bf6f0f6..031ef9ce059 100644
--- a/src/mongo/util/lruishmap.h
+++ b/src/mongo/util/lruishmap.h
@@ -43,7 +43,7 @@ namespace mongo {
int _find(const K& k, bool& found) {
int h = k.hash();
- assert( h > 0 );
+ verify( h > 0 );
int j = h % n;
int first = j;
for ( int i = 0; i < MaxChain; i++ ) {
diff --git a/src/mongo/util/mmap.cpp b/src/mongo/util/mmap.cpp
index 9865f16c484..29451ff2227 100755
--- a/src/mongo/util/mmap.cpp
+++ b/src/mongo/util/mmap.cpp
@@ -41,7 +41,7 @@ namespace mongo {
void *p = map(filename.c_str(), len);
if( p && zero ) {
size_t sz = (size_t) len;
- assert( len == sz );
+ verify( len == sz );
memset(p, 0, sz);
}
return p;
@@ -186,7 +186,7 @@ namespace mongo {
void MongoFile::setFilename(string fn) {
LockMongoFilesExclusive lk;
- assert( _filename.empty() );
+ verify( _filename.empty() );
_filename = fn;
MongoFile *&ptf = pathToFile[fn];
massert(13617, "MongoFile : multiple opens of same filename", ptf == 0);
diff --git a/src/mongo/util/mmap.h b/src/mongo/util/mmap.h
index f47f72c7c43..79fa787f244 100644
--- a/src/mongo/util/mmap.h
+++ b/src/mongo/util/mmap.h
@@ -152,7 +152,7 @@ namespace mongo {
virtual void* viewForFlushing() {
if( views.size() == 0 )
return 0;
- assert( views.size() == 1 );
+ verify( views.size() == 1 );
return views[0];
}
public:
@@ -246,18 +246,18 @@ namespace mongo {
}
bool get(unsigned i) const {
unsigned x = i / 32;
- assert( x < MemoryMappedFile::NChunks );
+ verify( x < MemoryMappedFile::NChunks );
return (bits[x] & (1 << (i%32))) != 0;
}
void set(unsigned i) {
unsigned x = i / 32;
wassert( x < (MemoryMappedFile::NChunks*2/3) ); // warn if getting close to limit
- assert( x < MemoryMappedFile::NChunks );
+ verify( x < MemoryMappedFile::NChunks );
bits[x] |= (1 << (i%32));
}
void clear(unsigned i) {
unsigned x = i / 32;
- assert( x < MemoryMappedFile::NChunks );
+ verify( x < MemoryMappedFile::NChunks );
bits[x] &= ~(1 << (i%32));
}
};
diff --git a/src/mongo/util/mmap_mm.cpp b/src/mongo/util/mmap_mm.cpp
index ec2400e02d3..a58aaaec040 100644
--- a/src/mongo/util/mmap_mm.cpp
+++ b/src/mongo/util/mmap_mm.cpp
@@ -37,7 +37,7 @@ namespace mongo {
}
void* MemoryMappedFile::map(const char *filename, long& length , int options ) {
- assert( length );
+ verify( length );
view = malloc( length );
return view;
}
diff --git a/src/mongo/util/mmap_posix.cpp b/src/mongo/util/mmap_posix.cpp
index f37f0448e02..eebed4f818b 100644
--- a/src/mongo/util/mmap_posix.cpp
+++ b/src/mongo/util/mmap_posix.cpp
@@ -76,7 +76,7 @@ namespace mongo {
switch ( a ) {
case Sequential: advice = MADV_SEQUENTIAL; break;
case Random: advice = MADV_RANDOM; break;
- default: assert(0);
+ default: verify(0);
}
if ( madvise(_p,_len,advice ) ) {
@@ -181,7 +181,7 @@ namespace mongo {
printMemInfo();
abort();
}
- assert( x == oldPrivateAddr );
+ verify( x == oldPrivateAddr );
return x;
}
diff --git a/src/mongo/util/mmap_win.cpp b/src/mongo/util/mmap_win.cpp
index 93896404ca2..b0c3a3e2726 100644
--- a/src/mongo/util/mmap_win.cpp
+++ b/src/mongo/util/mmap_win.cpp
@@ -35,7 +35,7 @@ namespace mongo {
void MemoryMappedFile::clearWritableBits(void *p) {
for( unsigned i = ((size_t)p)/ChunkSize; i <= (((size_t)p)+len)/ChunkSize; i++ ) {
writable.clear(i);
- assert( !writable.get(i) );
+ verify( !writable.get(i) );
}
}
@@ -67,7 +67,7 @@ namespace mongo {
unsigned long long mapped = 0;
void* MemoryMappedFile::createReadOnlyMap() {
- assert( maphandle );
+ verify( maphandle );
scoped_lock lk(mapViewMutex);
void *p = MapViewOfFile(maphandle, FILE_MAP_READ, /*f ofs hi*/0, /*f ofs lo*/ 0, /*dwNumberOfBytesToMap 0 means to eof*/0);
if ( p == 0 ) {
@@ -82,7 +82,7 @@ namespace mongo {
}
void* MemoryMappedFile::map(const char *filenameIn, unsigned long long &length, int options) {
- assert( fd == 0 && len == 0 ); // can't open more than once
+ verify( fd == 0 && len == 0 ); // can't open more than once
setFilename(filenameIn);
/* big hack here: Babble uses db names with colons. doesn't seem to work on windows. temporary perhaps. */
char filename[256];
diff --git a/src/mongo/util/mongoutils/test.cpp b/src/mongo/util/mongoutils/test.cpp
index 45268c5ca49..1a84e2d68af 100644
--- a/src/mongo/util/mongoutils/test.cpp
+++ b/src/mongo/util/mongoutils/test.cpp
@@ -30,16 +30,16 @@ int main() {
{
string s = "abcde";
str::stripTrailing(s, "ef");
- assert( s == "abcd" );
+ verify( s == "abcd" );
str::stripTrailing(s, "abcd");
- assert( s.empty() );
+ verify( s.empty() );
s = "abcddd";
str::stripTrailing(s, "d");
- assert( s == "abc" );
+ verify( s == "abc" );
}
string x = str::after("abcde", 'c');
- assert( x == "de" );
- assert( str::after("abcde", 'x') == "" );
+ verify( x == "de" );
+ verify( str::after("abcde", 'x') == "" );
return 0;
}
diff --git a/src/mongo/util/net/hostandport.h b/src/mongo/util/net/hostandport.h
index d05f13eb79c..2bfdb6d673c 100644
--- a/src/mongo/util/net/hostandport.h
+++ b/src/mongo/util/net/hostandport.h
@@ -40,7 +40,7 @@ namespace mongo {
/** @param p port number. -1 is ok to use default. */
HostAndPort(string h, int p /*= -1*/) : _host(h), _port(p) {
- assert( !str::startsWith(h, '#') );
+ verify( !str::startsWith(h, '#') );
}
HostAndPort(const SockAddr& sock ) : _host( sock.getAddr() ) , _port( sock.getPort() ) { }
@@ -158,8 +158,8 @@ namespace mongo {
}
string h = getHostName();
- assert( !h.empty() );
- assert( h != "localhost" );
+ verify( !h.empty() );
+ verify( h != "localhost" );
return HostAndPort(h, cmdLine.port);
}
@@ -208,8 +208,8 @@ namespace mongo {
inline void HostAndPort::init(const char *p) {
massert(13110, "HostAndPort: host is empty", *p);
- assert( *p != '#' );
- assert( _dynName.empty() );
+ verify( *p != '#' );
+ verify( _dynName.empty() );
const char *colon = strrchr(p, ':');
if( colon ) {
int port = atoi(colon+1);
diff --git a/src/mongo/util/net/httpclient.cpp b/src/mongo/util/net/httpclient.cpp
index 549734f4658..e94475a1940 100644
--- a/src/mongo/util/net/httpclient.cpp
+++ b/src/mongo/util/net/httpclient.cpp
@@ -121,7 +121,7 @@ namespace mongo {
int rc;
char version[32];
- assert( sscanf( buf , "%s %d" , version , &rc ) == 2 );
+ verify( sscanf( buf , "%s %d" , version , &rc ) == 2 );
HD( "rc: " << rc );
StringBuilder sb;
diff --git a/src/mongo/util/net/listen.cpp b/src/mongo/util/net/listen.cpp
index cba0c4610d5..7939399134e 100644
--- a/src/mongo/util/net/listen.cpp
+++ b/src/mongo/util/net/listen.cpp
@@ -341,7 +341,7 @@ namespace mongo {
}
void Listener::acceptedMP(MessagingPort *mp) {
- assert(!"You must overwrite one of the accepted methods");
+ verify(!"You must overwrite one of the accepted methods");
}
// ----- ListeningSockets -------
@@ -362,7 +362,7 @@ namespace mongo {
return DEFAULT_MAX_CONN;
#else
struct rlimit limit;
- assert( getrlimit(RLIMIT_NOFILE,&limit) == 0 );
+ verify( getrlimit(RLIMIT_NOFILE,&limit) == 0 );
int max = (int)(limit.rlim_cur * .8);
diff --git a/src/mongo/util/net/message.cpp b/src/mongo/util/net/message.cpp
index a84e5c48c5c..7c5aa4b9f89 100644
--- a/src/mongo/util/net/message.cpp
+++ b/src/mongo/util/net/message.cpp
@@ -47,7 +47,7 @@ namespace mongo {
/*struct MsgStart {
MsgStart() {
NextMsgId = (((unsigned) time(0)) << 16) ^ curTimeMillis();
- assert(MsgDataHeaderSize == 16);
+ verify(MsgDataHeaderSize == 16);
}
} msgstart;*/
diff --git a/src/mongo/util/net/message.h b/src/mongo/util/net/message.h
index c8ade44097d..46050c2d649 100644
--- a/src/mongo/util/net/message.h
+++ b/src/mongo/util/net/message.h
@@ -56,7 +56,7 @@ namespace mongo {
case dbKillCursors: return "killcursors";
default:
PRINT(op);
- assert(0);
+ verify(0);
return "";
}
}
@@ -79,7 +79,7 @@ namespace mongo {
default:
PRINT(op);
- assert(0);
+ verify(0);
return "";
}
@@ -129,8 +129,8 @@ namespace mongo {
}
long long getCursor() {
- assert( responseTo > 0 );
- assert( _operation == opReply );
+ verify( responseTo > 0 );
+ verify( _operation == opReply );
long long * l = (long long *)(_data + 4);
return l[0];
}
@@ -161,7 +161,7 @@ namespace mongo {
SockAddr _from;
MsgData *header() const {
- assert( !empty() );
+ verify( !empty() );
return _buf ? _buf : reinterpret_cast< MsgData* > ( _data[ 0 ].first );
}
int operation() const { return header()->operation(); }
@@ -195,7 +195,7 @@ namespace mongo {
return;
}
- assert( _freeIt );
+ verify( _freeIt );
int totalSize = 0;
for( vector< pair< char *, int > >::const_iterator i = _data.begin(); i != _data.end(); ++i ) {
totalSize += i->second;
@@ -212,8 +212,8 @@ namespace mongo {
// vector swap() so this is fast
Message& operator=(Message& r) {
- assert( empty() );
- assert( r._freeIt );
+ verify( empty() );
+ verify( r._freeIt );
_buf = r._buf;
r._buf = 0;
if ( r._data.size() > 0 ) {
@@ -250,7 +250,7 @@ namespace mongo {
_setData( md, true );
return;
}
- assert( _freeIt );
+ verify( _freeIt );
if ( _buf ) {
_data.push_back( make_pair( (char*)_buf, _buf->len ) );
_buf = 0;
@@ -261,14 +261,14 @@ namespace mongo {
// use to set first buffer if empty
void setData(MsgData *d, bool freeIt) {
- assert( empty() );
+ verify( empty() );
_setData( d, freeIt );
}
void setData(int operation, const char *msgtxt) {
setData(operation, msgtxt, strlen(msgtxt)+1);
}
void setData(int operation, const char *msgdata, size_t len) {
- assert( empty() );
+ verify( empty() );
size_t dataLen = len + sizeof(MsgData) - 4;
MsgData *d = (MsgData *) malloc(dataLen);
memcpy(d->_data, msgdata, len);
diff --git a/src/mongo/util/net/message_port.cpp b/src/mongo/util/net/message_port.cpp
index d0dc3cef28e..9a5a3ab1462 100644
--- a/src/mongo/util/net/message_port.cpp
+++ b/src/mongo/util/net/message_port.cpp
@@ -64,7 +64,7 @@ namespace mongo {
}
void append( Message& m ) {
- assert( m.header()->len <= 1300 );
+ verify( m.header()->len <= 1300 );
if ( len() + m.header()->len > 1300 )
flush();
@@ -180,10 +180,10 @@ again:
}
int z = (len+1023)&0xfffffc00;
- assert(z>=len);
+ verify(z>=len);
MsgData *md = (MsgData *) malloc(z);
ScopeGuard guard = MakeGuard(free, md);
- assert(md);
+ verify(md);
md->len = len;
char *p = (char *) &md->id;
@@ -234,7 +234,7 @@ again:
<< " response len: " << (unsigned)response.header()->len << '\n'
<< " response op: " << response.operation() << '\n'
<< " remote: " << psock->remoteString() << endl;
- assert(false);
+ verify(false);
response.reset();
}
mmm( log() << "*call() end" << endl; )
@@ -246,7 +246,7 @@ again:
}
void MessagingPort::say(Message& toSend, int responseTo) {
- assert( !toSend.empty() );
+ verify( !toSend.empty() );
mmm( log() << "* say() thr:" << GetCurrentThreadId() << endl; )
toSend.header()->id = nextMessageId();
toSend.header()->responseTo = responseTo;
diff --git a/src/mongo/util/net/message_server_asio.cpp b/src/mongo/util/net/message_server_asio.cpp
index 0c6a7d925da..52cf96d9578 100644
--- a/src/mongo/util/net/message_server_asio.cpp
+++ b/src/mongo/util/net/message_server_asio.cpp
@@ -105,7 +105,7 @@ namespace mongo {
MsgData * data = (MsgData*)raw;
memcpy( data , &_inHeader , sizeof( _inHeader ) );
- assert( data->len == _inHeader.len );
+ verify( data->len == _inHeader.len );
uassert( 10273 , "_cur not empty! pipelining requests not supported" , ! _cur.data );
@@ -127,7 +127,7 @@ namespace mongo {
if (!_myThread) // pool is empty
_myThread.reset(new StickyThread());
- assert(_myThread);
+ verify(_myThread);
_myThread->ready(shared_from_this());
}
@@ -150,7 +150,7 @@ namespace mongo {
{
// return thread to pool after we have sent data to the client
mongo::mutex::scoped_lock(tp_mutex);
- assert(_myThread);
+ verify(_myThread);
thread_pool.push_back(_myThread);
_myThread.reset();
}
diff --git a/src/mongo/util/net/message_server_port.cpp b/src/mongo/util/net/message_server_port.cpp
index a457c88193f..edb41bba37a 100644
--- a/src/mongo/util/net/message_server_port.cpp
+++ b/src/mongo/util/net/message_server_port.cpp
@@ -43,7 +43,7 @@ namespace mongo {
setThreadName( "conn" );
- assert( inPort );
+ verify( inPort );
inPort->psock->setLogLevel(1);
scoped_ptr<MessagingPort> p( inPort );
@@ -141,7 +141,7 @@ namespace mongo {
static const size_t STACK_SIZE = 1024*1024; // if we change this we need to update the warning
struct rlimit limits;
- assert(getrlimit(RLIMIT_STACK, &limits) == 0);
+ verify(getrlimit(RLIMIT_STACK, &limits) == 0);
if (limits.rlim_cur > STACK_SIZE) {
pthread_attr_setstacksize(&attrs, (DEBUG_BUILD
? (STACK_SIZE / 2)
diff --git a/src/mongo/util/net/miniwebserver.cpp b/src/mongo/util/net/miniwebserver.cpp
index 5c5d9daf471..60f738b53d1 100644
--- a/src/mongo/util/net/miniwebserver.cpp
+++ b/src/mongo/util/net/miniwebserver.cpp
@@ -156,7 +156,7 @@ namespace mongo {
}
else {
for ( vector<string>::iterator i = headers.begin(); i != headers.end(); i++ ) {
- assert( strncmp("Content-Length", i->c_str(), 14) );
+ verify( strncmp("Content-Length", i->c_str(), 14) );
ss << *i << "\r\n";
}
}
diff --git a/src/mongo/util/net/sock.cpp b/src/mongo/util/net/sock.cpp
index 946df432f39..b105a377a4b 100644
--- a/src/mongo/util/net/sock.cpp
+++ b/src/mongo/util/net/sock.cpp
@@ -201,7 +201,7 @@ namespace mongo {
}
else {
//TODO: handle other addresses in linked list;
- assert(addrs->ai_addrlen <= sizeof(sa));
+ verify(addrs->ai_addrlen <= sizeof(sa));
memcpy(&sa, addrs->ai_addr, addrs->ai_addrlen);
addressSize = addrs->ai_addrlen;
freeaddrinfo(addrs);
@@ -216,7 +216,7 @@ namespace mongo {
case AF_UNIX: return true;
default: return false;
}
- assert(false);
+ verify(false);
return false;
}
@@ -541,9 +541,9 @@ namespace mongo {
#ifdef MONGO_SSL
void Socket::secure( SSLManager * ssl ) {
- assert( ssl );
- assert( ! _ssl );
- assert( _fd >= 0 );
+ verify( ssl );
+ verify( ! _ssl );
+ verify( _fd >= 0 );
_ssl = ssl->secure( _fd );
SSL_connect( _ssl );
}
@@ -556,7 +556,7 @@ namespace mongo {
void Socket::postFork() {
#ifdef MONGO_SSL
if ( _sslAccepted ) {
- assert( _fd );
+ verify( _fd );
_ssl = _sslAccepted->secure( _fd );
SSL_accept( _ssl );
_sslAccepted = 0;
@@ -682,7 +682,7 @@ namespace mongo {
else {
_bytesOut += ret;
- assert( ret <= len );
+ verify( ret <= len );
len -= ret;
data += ret;
}
@@ -766,7 +766,7 @@ namespace mongo {
if ( ret > 0 ) {
if ( len <= 4 && ret != len )
log(_logLevel) << "Socket recv() got " << ret << " bytes wanted len=" << len << endl;
- assert( ret <= len );
+ verify( ret <= len );
len -= ret;
buf += ret;
}
diff --git a/src/mongo/util/processinfo_none.cpp b/src/mongo/util/processinfo_none.cpp
index 604018d32f2..8296c0cbbe1 100644
--- a/src/mongo/util/processinfo_none.cpp
+++ b/src/mongo/util/processinfo_none.cpp
@@ -58,7 +58,7 @@ namespace mongo {
}
bool ProcessInfo::blockInMemory( char * start ) {
- assert(0);
+ verify(0);
return true;
}
diff --git a/src/mongo/util/processinfo_win32.cpp b/src/mongo/util/processinfo_win32.cpp
index 6530e5fdaba..2dd3d1bbdaf 100755
--- a/src/mongo/util/processinfo_win32.cpp
+++ b/src/mongo/util/processinfo_win32.cpp
@@ -68,15 +68,15 @@ namespace mongo {
int ProcessInfo::getVirtualMemorySize() {
MEMORYSTATUSEX mse;
mse.dwLength = sizeof(mse);
- assert( GlobalMemoryStatusEx( &mse ) );
+ verify( GlobalMemoryStatusEx( &mse ) );
DWORDLONG x = (mse.ullTotalVirtual - mse.ullAvailVirtual) / (1024 * 1024) ;
- assert( x <= 0x7fffffff );
+ verify( x <= 0x7fffffff );
return (int) x;
}
int ProcessInfo::getResidentSize() {
PROCESS_MEMORY_COUNTERS pmc;
- assert( GetProcessMemoryInfo( GetCurrentProcess() , &pmc, sizeof(pmc) ) );
+ verify( GetProcessMemoryInfo( GetCurrentProcess() , &pmc, sizeof(pmc) ) );
return _wconvertmtos( pmc.WorkingSetSize );
}
diff --git a/src/mongo/util/ramlog.cpp b/src/mongo/util/ramlog.cpp
index d7a839a3fff..a4934f17be1 100644
--- a/src/mongo/util/ramlog.cpp
+++ b/src/mongo/util/ramlog.cpp
@@ -132,7 +132,7 @@ namespace mongo {
s << "<pre>\n";
for( int i = 0; i < (int)v.size(); i++ ) {
- assert( strlen(v[i]) > 20 );
+ verify( strlen(v[i]) > 20 );
int r = repeats(v, i);
if( r < 0 ) {
s << color( linkify( clean(v,i).c_str() ) ) << '\n';
diff --git a/src/mongo/util/text.cpp b/src/mongo/util/text.cpp
index a4091d684bb..3025d1da2b4 100644
--- a/src/mongo/util/text.cpp
+++ b/src/mongo/util/text.cpp
@@ -87,7 +87,7 @@ namespace mongo {
CP_UTF8, 0, wide.c_str(), static_cast<int>(wide.size()),
&buffer[0], static_cast<int>(buffer.size()), NULL, NULL);
if (len > 0) {
- assert(len == static_cast<int>(buffer.size()));
+ verify(len == static_cast<int>(buffer.size()));
return std::string(&buffer[0], buffer.size());
}
}
@@ -132,8 +132,8 @@ namespace mongo {
struct TextUnitTest : public UnitTest {
void run() {
- assert( parseLL("123") == 123 );
- assert( parseLL("-123000000000") == -123000000000LL );
+ verify( parseLL("123") == 123 );
+ verify( parseLL("-123000000000") == -123000000000LL );
}
} textUnitTest;
diff --git a/src/mongo/util/time_support.h b/src/mongo/util/time_support.h
index 69e32be709c..ad3cdbf4598 100644
--- a/src/mongo/util/time_support.h
+++ b/src/mongo/util/time_support.h
@@ -23,8 +23,6 @@
#include <boost/thread/tss.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread/xtime.hpp>
-#undef assert
-#define assert MONGO_assert
#include "../bson/util/misc.h" // Date_t
namespace mongo {
@@ -51,7 +49,7 @@ namespace mongo {
const char* fmt = (colonsOk ? "%Y-%m-%dT%H:%M:%S" : "%Y-%m-%dT%H-%M-%S");
char buf[32];
- assert(strftime(buf, sizeof(buf), fmt, &t) == 19);
+ verify(strftime(buf, sizeof(buf), fmt, &t) == 19);
return buf;
}
@@ -61,7 +59,7 @@ namespace mongo {
const char* fmt = "%Y-%m-%dT%H:%M:%SZ";
char buf[32];
- assert(strftime(buf, sizeof(buf), fmt, &t) == 20);
+ verify(strftime(buf, sizeof(buf), fmt, &t) == 20);
return buf;
}
@@ -104,7 +102,7 @@ namespace mongo {
Sleep(s*1000);
}
inline void sleepmillis(long long s) {
- assert( s <= 0xffffffff );
+ verify( s <= 0xffffffff );
Sleep((DWORD) s);
}
inline void sleepmicros(long long s) {
diff --git a/src/mongo/util/trace.cpp b/src/mongo/util/trace.cpp
index db81952e9eb..806f1fbd1e2 100755
--- a/src/mongo/util/trace.cpp
+++ b/src/mongo/util/trace.cpp
@@ -66,7 +66,7 @@ namespace mongo {
void Trace::setTraces(const string &names) {
/* create a new map, and replace the existing one */
NameMap *pM;
- assert(false);
+ verify(false);
}
#endif
diff --git a/src/mongo/util/util.cpp b/src/mongo/util/util.cpp
index bc4729be9b2..398997d9638 100644
--- a/src/mongo/util/util.cpp
+++ b/src/mongo/util/util.cpp
@@ -32,14 +32,14 @@ namespace mongo {
AtStartup() {
LARGE_INTEGER x;
bool ok = QueryPerformanceFrequency(&x);
- assert(ok);
+ verify(ok);
Timer::countsPerSecond = x.QuadPart;
}
} atstartuputil;
#endif
string hexdump(const char *data, unsigned len) {
- assert( len < 1000000 );
+ verify( len < 1000000 );
const unsigned char *p = (const unsigned char *) data;
stringstream ss;
for( unsigned i = 0; i < 4 && i < len; i++ ) {
@@ -167,19 +167,19 @@ namespace mongo {
struct UtilTest : public UnitTest {
void run() {
- assert( isPrime(3) );
- assert( isPrime(2) );
- assert( isPrime(13) );
- assert( isPrime(17) );
- assert( !isPrime(9) );
- assert( !isPrime(6) );
- assert( nextPrime(4) == 5 );
- assert( nextPrime(8) == 11 );
-
- assert( endsWith("abcde", "de") );
- assert( !endsWith("abcde", "dasdfasdfashkfde") );
-
- assert( swapEndian(0x01020304) == 0x04030201 );
+ verify( isPrime(3) );
+ verify( isPrime(2) );
+ verify( isPrime(13) );
+ verify( isPrime(17) );
+ verify( !isPrime(9) );
+ verify( !isPrime(6) );
+ verify( nextPrime(4) == 5 );
+ verify( nextPrime(8) == 11 );
+
+ verify( endsWith("abcde", "de") );
+ verify( !endsWith("abcde", "dasdfasdfashkfde") );
+
+ verify( swapEndian(0x01020304) == 0x04030201 );
}
} utilTest;
diff --git a/src/mongo/util/version.cpp b/src/mongo/util/version.cpp
index 1c4f658bf55..322a4c4e7e1 100644
--- a/src/mongo/util/version.cpp
+++ b/src/mongo/util/version.cpp
@@ -63,7 +63,7 @@ namespace mongo {
}
catch (...){ // not a number
if (curPart.empty()){
- assert(*c == '\0');
+ verify(*c == '\0');
break;
}
else if (startsWith(curPart, "rc")){
@@ -283,16 +283,16 @@ namespace mongo {
class VersionCmpTest : public UnitTest {
public:
void run() {
- assert( versionCmp("1.2.3", "1.2.3") == 0 );
- assert( versionCmp("1.2.3", "1.2.4") < 0 );
- assert( versionCmp("1.2.3", "1.2.20") < 0 );
- assert( versionCmp("1.2.3", "1.20.3") < 0 );
- assert( versionCmp("2.2.3", "10.2.3") < 0 );
- assert( versionCmp("1.2.3", "1.2.3-") > 0 );
- assert( versionCmp("1.2.3", "1.2.3-pre") > 0 );
- assert( versionCmp("1.2.3", "1.2.4-") < 0 );
- assert( versionCmp("1.2.3-", "1.2.3") < 0 );
- assert( versionCmp("1.2.3-pre", "1.2.3") < 0 );
+ verify( versionCmp("1.2.3", "1.2.3") == 0 );
+ verify( versionCmp("1.2.3", "1.2.4") < 0 );
+ verify( versionCmp("1.2.3", "1.2.20") < 0 );
+ verify( versionCmp("1.2.3", "1.20.3") < 0 );
+ verify( versionCmp("2.2.3", "10.2.3") < 0 );
+ verify( versionCmp("1.2.3", "1.2.3-") > 0 );
+ verify( versionCmp("1.2.3", "1.2.3-pre") > 0 );
+ verify( versionCmp("1.2.3", "1.2.4-") < 0 );
+ verify( versionCmp("1.2.3-", "1.2.3") < 0 );
+ verify( versionCmp("1.2.3-pre", "1.2.3") < 0 );
log(1) << "versionCmpTest passed" << endl;
}
@@ -301,22 +301,22 @@ namespace mongo {
class VersionArrayTest : public UnitTest {
public:
void run() {
- assert( _versionArray("1.2.3") == BSON_ARRAY(1 << 2 << 3 << 0) );
- assert( _versionArray("1.2.0") == BSON_ARRAY(1 << 2 << 0 << 0) );
- assert( _versionArray("2.0.0") == BSON_ARRAY(2 << 0 << 0 << 0) );
+ verify( _versionArray("1.2.3") == BSON_ARRAY(1 << 2 << 3 << 0) );
+ verify( _versionArray("1.2.0") == BSON_ARRAY(1 << 2 << 0 << 0) );
+ verify( _versionArray("2.0.0") == BSON_ARRAY(2 << 0 << 0 << 0) );
- assert( _versionArray("1.2.3-pre-") == BSON_ARRAY(1 << 2 << 3 << -100) );
- assert( _versionArray("1.2.0-pre-") == BSON_ARRAY(1 << 2 << 0 << -100) );
- assert( _versionArray("2.0.0-pre-") == BSON_ARRAY(2 << 0 << 0 << -100) );
+ verify( _versionArray("1.2.3-pre-") == BSON_ARRAY(1 << 2 << 3 << -100) );
+ verify( _versionArray("1.2.0-pre-") == BSON_ARRAY(1 << 2 << 0 << -100) );
+ verify( _versionArray("2.0.0-pre-") == BSON_ARRAY(2 << 0 << 0 << -100) );
- assert( _versionArray("1.2.3-rc0") == BSON_ARRAY(1 << 2 << 3 << -10) );
- assert( _versionArray("1.2.0-rc1") == BSON_ARRAY(1 << 2 << 0 << -9) );
- assert( _versionArray("2.0.0-rc2") == BSON_ARRAY(2 << 0 << 0 << -8) );
+ verify( _versionArray("1.2.3-rc0") == BSON_ARRAY(1 << 2 << 3 << -10) );
+ verify( _versionArray("1.2.0-rc1") == BSON_ARRAY(1 << 2 << 0 << -9) );
+ verify( _versionArray("2.0.0-rc2") == BSON_ARRAY(2 << 0 << 0 << -8) );
// Note that the pre of an rc is the same as the rc itself
- assert( _versionArray("1.2.3-rc3-pre-") == BSON_ARRAY(1 << 2 << 3 << -7) );
- assert( _versionArray("1.2.0-rc4-pre-") == BSON_ARRAY(1 << 2 << 0 << -6) );
- assert( _versionArray("2.0.0-rc5-pre-") == BSON_ARRAY(2 << 0 << 0 << -5) );
+ verify( _versionArray("1.2.3-rc3-pre-") == BSON_ARRAY(1 << 2 << 3 << -7) );
+ verify( _versionArray("1.2.0-rc4-pre-") == BSON_ARRAY(1 << 2 << 0 << -6) );
+ verify( _versionArray("2.0.0-rc5-pre-") == BSON_ARRAY(2 << 0 << 0 << -5) );
log(1) << "versionArrayTest passed" << endl;
}