0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

Merge branch 'master' of git@github.com:mongodb/mongo

This commit is contained in:
Aaron 2009-03-26 15:14:14 -04:00
commit 22ded53991
6 changed files with 35 additions and 26 deletions

View File

@ -258,7 +258,7 @@ elif "sunos5" == os.sys.platform:
useJavaHome = True
javaHome = "/usr/lib/jvm/java-6-sun/"
javaOS = "solaris"
env.Append( CPPDEFINES=[ "__linux__" ] )
env.Append( CPPDEFINES=[ "__linux__" , "__sunos__" ] )
elif "win32" == os.sys.platform:
windows = True
@ -714,7 +714,7 @@ def jsDirTestSpec( dir ):
return mongo[0].abspath + " --nodb " + jsSpec( [ dir, "*.js" ] )
# These tests require the mongo shell
if not onlyServer:
if not onlyServer and not noshell:
addSmoketest( "smokeJs", [ "mongo" ], [ mongo[0].abspath + " " + jsSpec( [ "_runner.js" ] ) ] )
addSmoketest( "smokeClone", [ "mongo", "mongod" ], [ jsDirTestSpec( "clone" ) ] )
addSmoketest( "smokeRepl", [ "mongo", "mongod" ], [ jsDirTestSpec( "repl" ) ] )

View File

@ -327,7 +327,7 @@ namespace mongo {
Timer startupSrandTimer;
void acquirePathLock() {
#if !defined(_WIN32)
#if !defined(_WIN32) and !defined(__sunos__)
string name = ( boost::filesystem::path( dbpath ) / "mongod.lock" ).native_file_string();
int f = open( name.c_str(), O_RDONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO );
massert( "Unable to create / open lock file for dbpath: " + name, f > 0 );

View File

@ -1,19 +1,19 @@
// storage.cpp
#include "stdafx.h"
int aaa;
#include "pdfile.h"
#include "reccache.h"
#include "rec.h"
#include "db.h"
namespace mongo {
RecCache theRecCache(BucketSize);
/* TODO MAKE CONFIGURABLE */
// 100k * 8KB = 800MB
unsigned RecCache::MAXNODES = 150000;
void writerThread() {
sleepsecs(10);
while( 1 ) {
@ -294,18 +294,13 @@ void RecCache::writeLazily() {
sleepmillis(sleep);
}
// 100k * 8KB = 800MB
const unsigned RECCACHELIMIT = 150000;
inline void RecCache::ejectOld() {
if( nnodes <= RECCACHELIMIT )
return;
void RecCache::_ejectOld() {
boostlock lk(rcmutex);
if( nnodes <= RECCACHELIMIT )
if( nnodes <= MAXNODES )
return;
Node *n = oldest;
while( 1 ) {
if( nnodes <= RECCACHELIMIT - 4 ) {
if( nnodes <= MAXNODES - 4 ) {
n->older = 0;
oldest = n;
assert( oldest ) ;
@ -396,9 +391,4 @@ void RecCache::drop(const char *_ns) {
}
}
void dbunlocking() {
dassert( dbMutexInfo.isLocked() );
theRecCache.ejectOld();
}
}

View File

@ -42,6 +42,7 @@ class RecCache {
vector<BasicRecStore*> stores; // DiskLoc::a() indicates the index into this vector
map<string, BasicRecStore*> storesByNsKey; // nskey -> BasicRecStore*
public:
static unsigned MAXNODES;
enum { Base = 10000 };
private:
BasicRecStore* _initStore(string fname);
@ -112,6 +113,7 @@ private:
}
void dump();
void _ejectOld();
public:
/* all public functions (except constructor) should use the mutex */
@ -124,7 +126,10 @@ public:
/* call this after doing some work, after you are sure you are done with modifications.
we call it from dbunlocking().
*/
void ejectOld();
void ejectOld() {
if( nnodes > MAXNODES ) // just enough here to be inlineable for speed reasons. _ejectOld does the real work
_ejectOld();
}
/* bg writer thread invokes this */
void writeLazily();
@ -214,4 +219,9 @@ public:
}
};
inline void dbunlocking() {
// dassert( dbMutexInfo.isLocked() );
theRecCache.ejectOld();
}
} /*namespace*/

View File

@ -350,6 +350,7 @@ void writeMongoProgramOutputLine( int port, const char *line ) {
class MongoProgramRunner {
char **argv_;
int port_;
int pipe_;
public:
MongoProgramRunner( const v8::Arguments &args ) {
assert( args.Length() > 0 );
@ -386,7 +387,7 @@ public:
assert( dbs.count( port_ ) == 0 );
}
void operator()() {
void start() {
int pipeEnds[ 2 ];
assert( pipe( pipeEnds ) != -1 );
@ -407,7 +408,11 @@ public:
free( argv_ );
dbs.insert( make_pair( port_, make_pair( pid, pipeEnds[ 1 ] ) ) );
pipe_ = pipeEnds[ 0 ];
}
// Continue reading output
void operator()() {
// This assumes there aren't any 0's in the mongo program output.
// Hope that's ok.
char buf[ 1024 ];
@ -415,7 +420,7 @@ public:
char *start = buf;
while( 1 ) {
int lenToRead = 1023 - ( start - buf );
int ret = read( pipeEnds[ 0 ], (void *)start, lenToRead );
int ret = read( pipe_, (void *)start, lenToRead );
assert( ret != -1 );
start[ ret ] = '\0';
char *last = buf;
@ -441,6 +446,7 @@ public:
v8::Handle< v8::Value > StartMongoProgram( const v8::Arguments &a ) {
MongoProgramRunner r( a );
r.start();
boost::thread t( r );
return v8::Undefined();
}
@ -494,8 +500,11 @@ v8::Handle< v8::Value > StopMongoProgram( const v8::Arguments &a ) {
}
void KillMongoProgramInstances() {
vector< int > ports;
for( map< int, pair< pid_t, int > >::iterator i = dbs.begin(); i != dbs.end(); ++i )
killDb( i->first, SIGTERM );
ports.push_back( i->first );
for( vector< int >::iterator i = ports.begin(); i != ports.end(); ++i )
killDb( *i, SIGTERM );
}
MongoProgramScope::~MongoProgramScope() {

View File

@ -75,7 +75,7 @@ inline void printStackTrace() {
}
void quitAbruptly( int sig ) {
cout << "mongo got signal" << sig << " (" << strsignal( sig ) << "), stack trace: " << endl;
cout << "mongo got signal " << sig << " (" << strsignal( sig ) << "), stack trace: " << endl;
printStackTrace();
KillMongoProgramInstances();
exit(14);