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

add dbtempreleasecond that only releases if you have a single level lock

This commit is contained in:
Eliot Horowitz 2009-12-17 20:45:54 -05:00
parent 0d1a097017
commit 4ea2e8ff49
3 changed files with 45 additions and 1 deletions

23
db/db.h
View File

@ -156,6 +156,29 @@ namespace mongo {
}
};
/**
only does a temp release if we're not nested and have a lock
*/
struct dbtempreleasecond {
dbtemprelease * real;
int locktype;
dbtempreleasecond(){
real = 0;
locktype = dbMutex.getState();
if ( locktype == 1 || locktype == -1 )
real = new dbtemprelease();
}
~dbtempreleasecond(){
if ( real ){
delete real;
real = 0;
}
}
};
} // namespace mongo
#include "dbinfo.h"

View File

@ -155,7 +155,7 @@ namespace mongo {
cc->updateLocation();
cc->setDoingDeletes( false );
{
dbtemprelease unlock;
dbtempreleasecond unlock;
}
if ( ClientCursor::find( id , false ) == 0 ){
cc.reset( 0 );

21
jstests/remove8.js Normal file
View File

@ -0,0 +1,21 @@
t = db.remove8;
t.drop();
N = 1000;
function fill(){
for ( var i=0; i<N; i++ ){
t.save( { x : i } );
}
}
fill();
assert.eq( N , t.count() , "A" );
t.remove( {} )
assert.eq( 0 , t.count() , "B" );
fill();
assert.eq( N , t.count() , "C" );
db.eval( function(){ db.remove8.remove( {} ); } )
assert.eq( 0 , t.count() , "D" );