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:
parent
0d1a097017
commit
4ea2e8ff49
23
db/db.h
23
db/db.h
@ -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"
|
||||
|
@ -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
21
jstests/remove8.js
Normal 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" );
|
Loading…
Reference in New Issue
Block a user