diff options
-rw-r--r-- | SConstruct | 3 | ||||
-rw-r--r-- | db/storage.cpp | 106 | ||||
-rw-r--r-- | dbtests/perf/perftest.cpp | 6 |
3 files changed, 59 insertions, 56 deletions
diff --git a/SConstruct b/SConstruct index 6c328ed5496..64b45653d8a 100644 --- a/SConstruct +++ b/SConstruct @@ -328,7 +328,8 @@ if useJavaHome: if nix: - env.Append( CPPFLAGS="-fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wnon-virtual-dtor" ) + env.Append( CPPFLAGS="-fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare" ) + env.Append( CXXFLAGS=" -Wnon-virtual-dtor " ) env.Append( LINKFLAGS=" -fPIC " ) env.Append( LIBS=[] ) diff --git a/db/storage.cpp b/db/storage.cpp index 93fe869be5a..a93b53a4ecb 100644 --- a/db/storage.cpp +++ b/db/storage.cpp @@ -1,17 +1,19 @@ -// storage.cpp
-
-#include "stdafx.h"
-#include "pdfile.h"
-#include "reccache.h"
-#include "rec.h"
-#include "db.h"
-
-namespace mongo {
-
-void writerThread();
-
-static int inited;
-
+// storage.cpp + +#include "stdafx.h" +#include "pdfile.h" +#include "reccache.h" +#include "rec.h" +#include "db.h" + +namespace mongo { + +void writerThread(); + +#if defined(_RECSTORE) + static int inited; +#endif + // pick your store for indexes by setting this typedef // this doesn't need to be an ifdef, we can make it dynamic #if defined(_RECSTORE) @@ -19,41 +21,41 @@ RecStoreInterface *btreeStore = new CachedBasicRecStore(); #else RecStoreInterface *btreeStore = new MongoMemMapped_RecStore(); #endif -
-void BasicRecStore::init(const char *fn, unsigned recsize)
-{
- massert( "compile packing problem recstore?", sizeof(RecStoreHeader) == 8192);
- filename = fn;
- f.open(fn);
- uassert( string("couldn't open file:")+fn, f.is_open() );
- len = f.len();
- if( len == 0 ) {
- log() << "creating recstore file " << fn << '\n';
- h.recsize = recsize;
- len = sizeof(RecStoreHeader);
- f.write(0, (const char *) &h, sizeof(RecStoreHeader));
- }
- else {
- f.read(0, (char *) &h, sizeof(RecStoreHeader));
- massert(string("recstore was not closed cleanly: ")+fn, h.cleanShutdown==0);
- massert(string("recstore recsize mismatch, file:")+fn, h.recsize == recsize);
- massert(string("bad recstore [1], file:")+fn, (h.leof-sizeof(RecStoreHeader)) % recsize == 0);
- if( h.leof > len ) {
- stringstream ss;
- ss << "bad recstore, file:" << fn << " leof:" << h.leof << " len:" << len;
- massert(ss.str(), false);
- }
- if( h.cleanShutdown )
- log() << "warning: non-clean shutdown for file " << fn << '\n';
- h.cleanShutdown = 2;
- writeHeader();
- f.fsync();
- }
-#if defined(_RECSTORE)
- if( inited++ == 0 ) {
- boost::thread t(writerThread);
- }
-#endif
-}
-
-}
+ +void BasicRecStore::init(const char *fn, unsigned recsize) +{ + massert( "compile packing problem recstore?", sizeof(RecStoreHeader) == 8192); + filename = fn; + f.open(fn); + uassert( string("couldn't open file:")+fn, f.is_open() ); + len = f.len(); + if( len == 0 ) { + log() << "creating recstore file " << fn << '\n'; + h.recsize = recsize; + len = sizeof(RecStoreHeader); + f.write(0, (const char *) &h, sizeof(RecStoreHeader)); + } + else { + f.read(0, (char *) &h, sizeof(RecStoreHeader)); + massert(string("recstore was not closed cleanly: ")+fn, h.cleanShutdown==0); + massert(string("recstore recsize mismatch, file:")+fn, h.recsize == recsize); + massert(string("bad recstore [1], file:")+fn, (h.leof-sizeof(RecStoreHeader)) % recsize == 0); + if( h.leof > len ) { + stringstream ss; + ss << "bad recstore, file:" << fn << " leof:" << h.leof << " len:" << len; + massert(ss.str(), false); + } + if( h.cleanShutdown ) + log() << "warning: non-clean shutdown for file " << fn << '\n'; + h.cleanShutdown = 2; + writeHeader(); + f.fsync(); + } +#if defined(_RECSTORE) + if( inited++ == 0 ) { + boost::thread t(writerThread); + } +#endif +} + +} diff --git a/dbtests/perf/perftest.cpp b/dbtests/perf/perftest.cpp index fc1cd7a4392..cc4afa576d9 100644 --- a/dbtests/perf/perftest.cpp +++ b/dbtests/perf/perftest.cpp @@ -541,7 +541,7 @@ namespace QueryTests { client_->insert( ns_.c_str(), obj ); } void run() { - ASSERT_EQUALS( 100000, client_->count( ns_, BSON( "a" << 1 ) ) ); + ASSERT_EQUALS( 100000U, client_->count( ns_, BSON( "a" << 1 ) ) ); } string ns_; }; @@ -555,7 +555,7 @@ namespace QueryTests { client_->ensureIndex( ns_, obj ); } void run() { - ASSERT_EQUALS( 100000, client_->count( ns_, BSON( "a" << GTE << 1 ) ) ); + ASSERT_EQUALS( 100000U, client_->count( ns_, BSON( "a" << GTE << 1 ) ) ); } string ns_; }; @@ -569,7 +569,7 @@ namespace QueryTests { client_->ensureIndex( ns_, obj ); } void run() { - ASSERT_EQUALS( 100000, client_->count( ns_, BSON( "a" << 1 ) ) ); + ASSERT_EQUALS( 100000U, client_->count( ns_, BSON( "a" << 1 ) ) ); } string ns_; }; |