summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/threadedtests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/dbtests/threadedtests.cpp')
-rw-r--r--src/mongo/dbtests/threadedtests.cpp55
1 files changed, 34 insertions, 21 deletions
diff --git a/src/mongo/dbtests/threadedtests.cpp b/src/mongo/dbtests/threadedtests.cpp
index b5537364525..96e6e0df7b4 100644
--- a/src/mongo/dbtests/threadedtests.cpp
+++ b/src/mongo/dbtests/threadedtests.cpp
@@ -35,6 +35,7 @@
#include "mongo/bson/util/atomic_int.h"
#include "mongo/db/d_concurrency.h"
+#include "mongo/db/operation_context_impl.h"
#include "mongo/dbtests/dbtests.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/stdx/functional.h"
@@ -115,6 +116,8 @@ namespace ThreadedTests {
}
virtual void subthread(int tnumber) {
Client::initThread("mongomutextest");
+ LockState lockState;
+
sleepmillis(0);
for( int i = 0; i < N; i++ ) {
int x = std::rand();
@@ -169,13 +172,13 @@ namespace ThreadedTests {
}
else if( i % 7 == 5 ) {
{
- Lock::DBRead r("foo");
+ Lock::DBRead r(&lockState, "foo");
if( sometimes ) {
Lock::TempRelease t;
}
}
{
- Lock::DBRead r("bar");
+ Lock::DBRead r(&lockState, "bar");
}
}
else if( i % 7 == 6 ) {
@@ -183,13 +186,13 @@ namespace ThreadedTests {
int q = i % 11;
if( q == 0 ) {
char what = 'r';
- Lock::DBRead r("foo");
+ Lock::DBRead r(&lockState, "foo");
ASSERT( Lock::isLocked() == what && Lock::atLeastReadLocked("foo") );
ASSERT( !Lock::nested() );
- Lock::DBRead r2("foo");
+ Lock::DBRead r2(&lockState, "foo");
ASSERT( Lock::nested() );
ASSERT( Lock::isLocked() == what && Lock::atLeastReadLocked("foo") );
- Lock::DBRead r3("local");
+ Lock::DBRead r3(&lockState, "local");
if( sometimes ) {
Lock::TempRelease t;
}
@@ -199,41 +202,48 @@ namespace ThreadedTests {
else if( q == 1 ) {
// test locking local only -- with no preceeding lock
{
- Lock::DBRead x("local");
+ Lock::DBRead x(&lockState, "local");
//Lock::DBRead y("q");
if( sometimes ) {
Lock::TempRelease t; // we don't temprelease (cant=true) here thus this is just a check that nothing weird happens...
}
}
- {
- Lock::DBWrite x("local");
+ {
+ OperationContextImpl txn;
+ Lock::DBWrite x(txn.lockState(), "local");
if( sometimes ) {
Lock::TempRelease t;
}
}
} else if( q == 1 ) {
- { Lock::DBRead x("admin"); }
- { Lock::DBWrite x("admin"); }
+ { Lock::DBRead x(&lockState, "admin"); }
+ {
+ OperationContextImpl txn;
+ Lock::DBWrite x(txn.lockState(), "admin");
+ }
} else if( q == 2 ) {
/*Lock::DBWrite x("foo");
Lock::DBWrite y("admin");
{ Lock::TempRelease t; }*/
}
else if( q == 3 ) {
- Lock::DBWrite x("foo");
- Lock::DBRead y("admin");
+ OperationContextImpl txn;
+ Lock::DBWrite x(txn.lockState(), "foo");
+ Lock::DBRead y(&lockState, "admin");
{ Lock::TempRelease t; }
}
else if( q == 4 ) {
- Lock::DBRead x("foo2");
- Lock::DBRead y("admin");
+ Lock::DBRead x(&lockState, "foo2");
+ Lock::DBRead y(&lockState, "admin");
{ Lock::TempRelease t; }
}
else if ( q > 4 && q < 8 ) {
static const char * const dbnames[] = {
"bar0", "bar1", "bar2", "bar3", "bar4", "bar5",
"bar6", "bar7", "bar8", "bar9", "bar10" };
- Lock::DBWrite w(dbnames[q]);
+
+ OperationContextImpl txn;
+ Lock::DBWrite w(txn.lockState(), dbnames[q]);
{
Lock::UpgradeGlobalLockToExclusive wToX;
if (wToX.gotUpgrade()) {
@@ -245,21 +255,24 @@ namespace ThreadedTests {
}
}
else {
- Lock::DBWrite w("foo");
+ OperationContextImpl txn;
+ Lock::DBWrite w(txn.lockState(), "foo");
+
{
Lock::TempRelease t;
}
- Lock::DBRead r2("foo");
- Lock::DBRead r3("local");
+
+ Lock::DBRead r2(&lockState, "foo");
+ Lock::DBRead r3(&lockState, "local");
if( sometimes ) {
Lock::TempRelease t;
}
}
}
else {
- Lock::DBRead r("foo");
- Lock::DBRead r2("foo");
- Lock::DBRead r3("local");
+ Lock::DBRead r(&lockState, "foo");
+ Lock::DBRead r2(&lockState, "foo");
+ Lock::DBRead r3(&lockState, "local");
}
}
pm.hit();