diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-02-10 15:16:00 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-02-10 15:16:00 -0500 |
commit | b88e91c8f56fcbd309bd1b2fc337d5c877ccc3b4 (patch) | |
tree | 33fd123cc9d9989bbb37788b5bae1460b9f8600f | |
parent | f765ec0442d243cdbd47713b6d63a1237dde863b (diff) | |
download | mongo-b88e91c8f56fcbd309bd1b2fc337d5c877ccc3b4.tar.gz |
clean up curop read/write detection
-rw-r--r-- | db/client.cpp | 4 | ||||
-rw-r--r-- | db/concurrency.h | 6 | ||||
-rw-r--r-- | db/curop.h | 13 | ||||
-rw-r--r-- | db/instance.cpp | 5 |
4 files changed, 10 insertions, 18 deletions
diff --git a/db/client.cpp b/db/client.cpp index da205df75fb..a2dca9a43de 100644 --- a/db/client.cpp +++ b/db/client.cpp @@ -156,12 +156,12 @@ namespace mongo { return c->toString(); } - void curopWaitingForLock(){ + void curopWaitingForLock( int type ){ Client * c = currentClient.get(); assert( c ); CurOp * co = c->curop(); if ( co ){ - co->waitingForLock(); + co->waitingForLock( type ); } } void curopGotLock(){ diff --git a/db/concurrency.h b/db/concurrency.h index 14aa33be19e..2bcabe5ad8c 100644 --- a/db/concurrency.h +++ b/db/concurrency.h @@ -50,7 +50,7 @@ namespace mongo { string sayClientState(); - void curopWaitingForLock(); + void curopWaitingForLock( int type ); void curopGotLock(); /* mutex time stats */ @@ -122,7 +122,7 @@ namespace mongo { massert( 10293 , (string)"internal error: locks are not upgradeable: " + sayClientState() , s == 0 ); _state.set(1); - curopWaitingForLock(); + curopWaitingForLock( 1 ); _m.lock(); curopGotLock(); @@ -173,7 +173,7 @@ namespace mongo { } } _state.set(-1); - curopWaitingForLock(); + curopWaitingForLock( -1 ); _m.lock_shared(); curopGotLock(); } diff --git a/db/curop.h b/db/curop.h index fd0097690ae..2b33b485b1d 100644 --- a/db/curop.h +++ b/db/curop.h @@ -114,15 +114,12 @@ namespace mongo { _op = op; } - void setRead(){ - _lockType = -1; - } - void setWrite(){ - _lockType = 1; - } - - void waitingForLock(){ + void waitingForLock( int type ){ _waitingForLock = true; + if ( type > 0 ) + _lockType = 1; + else + _lockType = -1; } void gotLock(){ _waitingForLock = false; diff --git a/db/instance.cpp b/db/instance.cpp index f53a8e7712f..e4ff204c0a0 100644 --- a/db/instance.cpp +++ b/db/instance.cpp @@ -171,7 +171,6 @@ namespace mongo { if (q.fields.get() && q.fields->errmsg) uassert( 10053 , q.fields->errmsg, false); - c.curop()->setRead(); msgdata = runQuery(m, q, op ).release(); } catch ( AssertionException& e ) { @@ -454,7 +453,6 @@ namespace mongo { mongolock lk(1); Client::Context ctx( ns ); - op.setWrite(); UpdateResult res = updateObjects(ns, toupdate, query, upsert, multi, true, op.debug() ); recordUpdate( res.existing , (int) res.num ); // for getlasterror @@ -466,7 +464,6 @@ namespace mongo { assert(*ns); uassert( 10056 , "not master", isMasterNs( ns ) ); Client::Context ctx(ns); - op.setWrite(); int flags = d.pullInt(); bool justOne = flags & 1; assert( d.moreJSObjs() ); @@ -490,7 +487,6 @@ namespace mongo { ss << ns; mongolock lk(false); Client::Context ctx(ns); - curop.setRead(); int ntoreturn = d.pullInt(); long long cursorid = d.pullInt64(); ss << " cid:" << cursorid; @@ -520,7 +516,6 @@ namespace mongo { assert(*ns); uassert( 10058 , "not master", isMasterNs( ns ) ); Client::Context ctx(ns); - op.setWrite(); op.debug().str << ns; while ( d.moreJSObjs() ) { |