diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/curop.h | 11 | ||||
-rw-r--r-- | src/mongo/db/kill_current_op.cpp | 23 | ||||
-rw-r--r-- | src/mongo/db/parsed_query.cpp | 5 | ||||
-rw-r--r-- | src/mongo/shell/query.js | 12 |
4 files changed, 36 insertions, 15 deletions
diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h index 0fc0de64a1d..95bbfbaa8b9 100644 --- a/src/mongo/db/curop.h +++ b/src/mongo/db/curop.h @@ -175,8 +175,6 @@ namespace mongo { BSONObj query() const { return _query.get(); } void appendQuery( BSONObjBuilder& b , const StringData& name ) const { _query.append( b , name ); } - void ensureStarted(); - bool isStarted() const { return _start > 0; } void enter( Client::Context * context ); void leave( Client::Context * context ); void reset(); @@ -200,6 +198,13 @@ namespace mongo { bool displayInCurop() const { return _active && ! _suppressFromCurop; } int getOp() const { return _op; } + + // + // Methods for getting/setting elapsed time. + // + + void ensureStarted(); + bool isStarted() const { return _start > 0; } unsigned long long startTime() { // micros ensureStarted(); return _start; @@ -208,6 +213,7 @@ namespace mongo { _active = false; _end = curTimeMicros64(); } + unsigned long long totalTimeMicros() { massert( 12601 , "CurOp not marked done yet" , ! _active ); return _end - startTime(); @@ -218,6 +224,7 @@ namespace mongo { return (int) (total / 1000); } int elapsedSeconds() { return elapsedMillis() / 1000; } + void setQuery(const BSONObj& query) { _query.set( query ); } Client * getClient() const { return _client; } diff --git a/src/mongo/db/kill_current_op.cpp b/src/mongo/db/kill_current_op.cpp index d036d11c000..a938489ecc9 100644 --- a/src/mongo/db/kill_current_op.cpp +++ b/src/mongo/db/kill_current_op.cpp @@ -104,24 +104,31 @@ namespace mongo { _condvar.notify_all(); } - void KillCurrentOp::checkForInterrupt( bool heedMutex ) { + void KillCurrentOp::checkForInterrupt(bool heedMutex) { Client& c = cc(); - if ( heedMutex && Lock::somethingWriteLocked() && c.hasWrittenThisPass() ) + + if (heedMutex && Lock::somethingWriteLocked() && c.hasWrittenThisPass()) { return; - if( _globalKill ) - uasserted(11600,"interrupted at shutdown"); - if( c.curop()->killPending() ) { + } + + if (_globalKill) { + uasserted(11600, "interrupted at shutdown"); + } + if (c.curop()->killPending()) { notifyAllWaiters(); - uasserted(11601,"operation was interrupted"); + uasserted(11601, "operation was interrupted"); } } const char * KillCurrentOp::checkForInterruptNoAssert() { Client& c = cc(); - if( _globalKill ) + + if (_globalKill) { return "interrupted at shutdown"; - if( c.curop()->killPending() ) + } + if (c.curop()->killPending()) { return "interrupted"; + } return ""; } diff --git a/src/mongo/db/parsed_query.cpp b/src/mongo/db/parsed_query.cpp index 232792efdc5..ad23acef3b8 100644 --- a/src/mongo/db/parsed_query.cpp +++ b/src/mongo/db/parsed_query.cpp @@ -99,6 +99,11 @@ namespace mongo { _filter = _filter.getOwned(); + // + // Parse options that are valid for both queries and commands + // + + // $readPreference _hasReadPref = q.hasField(Query::ReadPrefField.name()); } diff --git a/src/mongo/shell/query.js b/src/mongo/shell/query.js index 0c0cbd27464..33aa7f0c00d 100644 --- a/src/mongo/shell/query.js +++ b/src/mongo/shell/query.js @@ -161,17 +161,19 @@ DBQuery.prototype.toArray = function(){ return a; } -DBQuery.prototype.count = function( applySkipLimit ){ +DBQuery.prototype.count = function( applySkipLimit ) { var cmd = { count: this._collection.getName() }; - if ( this._query ){ - if ( this._special ) + if ( this._query ) { + if ( this._special ) { cmd.query = this._query.query; - else + } + else { cmd.query = this._query; + } } cmd.fields = this._fields || {}; - if ( applySkipLimit ){ + if ( applySkipLimit ) { if ( this._limit ) cmd.limit = this._limit; if ( this._skip ) |