summaryrefslogtreecommitdiff
path: root/src/mongo/db/curop.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/curop.cpp')
-rw-r--r--src/mongo/db/curop.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp
index 68e24e2b171..66e0138ee0f 100644
--- a/src/mongo/db/curop.cpp
+++ b/src/mongo/db/curop.cpp
@@ -67,6 +67,44 @@ namespace mongo {
_active = true; // this should be last for ui clarity
}
+ CurOp* CurOp::getOp(const BSONObj& criteria) {
+ // Regarding Matcher: This is not quite the right hammer to use here.
+ // Future: use an actual property of CurOp to flag index builds
+ // and use that to filter.
+ // This will probably need refactoring once we change index builds
+ // to be a real command instead of an insert into system.indexes
+ Matcher matcher(criteria);
+
+ Client& me = cc();
+
+ scoped_lock client_lock(Client::clientsMutex);
+ for (std::set<Client*>::iterator it = Client::clients.begin();
+ it != Client::clients.end();
+ it++) {
+
+ Client *client = *it;
+ verify(client);
+
+ CurOp* curop = client->curop();
+ if (client == &me || curop == NULL) {
+ continue;
+ }
+
+ if ( !curop->active() )
+ continue;
+
+ if ( curop->killPendingStrict() )
+ continue;
+
+ BSONObj info = curop->info();
+ if (matcher.matches(info)) {
+ return curop;
+ }
+ }
+
+ return NULL;
+ }
+
void CurOp::reset( const HostAndPort& remote, int op ) {
reset();
if( _remote != remote ) {