summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2013-07-26 12:05:39 -0400
committerJason Rassi <rassi@10gen.com>2013-07-26 16:36:07 -0400
commite721e9df43caf1433040dde1fd7ff54384f2497d (patch)
tree79f51fc3399d95ad6e1990b78a9f635fe58b2184 /src
parenta856222627ce97d1ace25a14d6f2b69e8471a1e6 (diff)
downloadmongo-e721e9df43caf1433040dde1fd7ff54384f2497d.tar.gz
SERVER-2212 Misc. comments, formatting
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/curop.h11
-rw-r--r--src/mongo/db/kill_current_op.cpp23
-rw-r--r--src/mongo/db/parsed_query.cpp5
-rw-r--r--src/mongo/shell/query.js12
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 )