0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00

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

This commit is contained in:
Aaron 2009-03-27 16:27:44 -04:00
commit 743e44eed2
5 changed files with 30 additions and 12 deletions

View File

@ -82,6 +82,19 @@ namespace mongo {
delete (*i);
}
/* called every 4 seconds. millis is amount of idle time passed since the last call -- could be zero */
void idleTimeReport(unsigned millis) {
assert( dbMutexInfo.isLocked() );
for ( ByLoc::iterator i = byLoc.begin(); i != byLoc.end(); ) {
ByLoc::iterator j = i;
i++;
if( (j->second->idleAgeMillis += millis) > 60000 ) {
log(2) << "killing old cursor " << j->second->cursorid << ' ' << j->second->ns << " idle:" << j->second->idleAgeMillis << "ms\n";
delete j->second;
}
}
}
/* must call when a btree bucket going away.
note this is potentially slow
*/
@ -150,6 +163,7 @@ namespace mongo {
*/
void ClientCursor::updateLocation() {
assert( cursorid );
idleAgeMillis = 0;
DiskLoc cl = c->refLoc();
if ( lastLoc() == cl ) {
//log() << "info: lastloc==curloc " << ns << '\n';

View File

@ -38,7 +38,7 @@ namespace mongo {
DiskLoc _lastLoc; // use getter and setter not this.
static CursorId allocCursorId();
public:
ClientCursor() : cursorid( allocCursorId() ), pos(0) {
ClientCursor() : cursorid( allocCursorId() ), pos(0), idleAgeMillis(0) {
clientCursorsById.insert( make_pair(cursorid, this) );
}
~ClientCursor();
@ -52,7 +52,8 @@ namespace mongo {
}
void setLastLoc(DiskLoc);
auto_ptr< set<string> > filter; // which fields query wants returned
Message originalMessage; // this is effectively an auto ptr for data the matcher points to.
Message originalMessage; // this is effectively an auto ptr for data the matcher points to
unsigned idleAgeMillis; // how long has the cursor been around, relative to server idle time
/* Get rid of cursors for namespaces that begin with nsprefix.
Used by drop, deleteIndexes, dropDatabase.

View File

@ -61,6 +61,8 @@ namespace mongo {
unsigned q = 0;
extern bool cpu;
void idleTimeReport(unsigned millis);
void statsThread() {
unsigned long long timeLastPass = 0;
while ( 1 ) {
@ -85,6 +87,7 @@ namespace mongo {
if ( cpu )
log() << "cpu: " << s << endl;
lockStats[q] = s;
idleTimeReport( (unsigned) ((dt - dlocked)/1000) );
}
}
timeLastPass = now;

View File

@ -79,7 +79,7 @@ DBCollection.prototype._massageObject = function( q ){
}
DBCollection.prototype._validateForStorage = function( o ){
for ( k in o ){
for ( var k in o ){
if ( k.indexOf( "." ) >= 0 )
throw "can't have . in field names [" + k + "]" ;
}
@ -129,7 +129,7 @@ DBCollection.prototype.save = function( obj ){
DBCollection.prototype._genIndexName = function( keys ){
var name = "";
for ( k in keys ){
for ( var k in keys ){
if ( name.length > 0 )
name += "_";
name += k + "_";

View File

@ -313,7 +313,7 @@ int main(int argc, char* argv[]) {
cout << "type \"help\" for help" << endl;
v8::Handle<v8::Object> shellHelper = baseContext_->Global()->Get( v8::String::New( "shellHelper" ) )->ToObject();
while ( 1 ){
char * line = shellReadline( "> " );
@ -325,9 +325,9 @@ int main(int argc, char* argv[]) {
string code = line;
if ( code == "exit" ){
break;
}
break;
}
{
string cmd = line;
if ( cmd.find( " " ) > 0 )
@ -340,18 +340,18 @@ int main(int argc, char* argv[]) {
}
}
v8::HandleScope handle_scope;
ExecuteString(v8::String::New( code.c_str() ),
v8::String::New("(shell)"),
true,
true);
shellHistoryAdd( line );
shellHistoryAdd( line );
}
shellHistoryDone();
shellHistoryDone();
}
return 0;