summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2012-10-09 13:24:41 -0400
committerEric Milkie <milkie@10gen.com>2012-10-10 16:31:14 -0400
commit7922e03d36d059a6602541d83b6a26224e6178dd (patch)
tree5a6ba05cda0716769ca3e656e477b74c0398cdc1
parentf0a5062ff9651f97ac58ef1f50f91b0a5f653798 (diff)
downloadmongo-7922e03d36d059a6602541d83b6a26224e6178dd.tar.gz
SERVER-2771 preliminary code cleanup; no functional change
-rw-r--r--src/mongo/SConscript1
-rw-r--r--src/mongo/db/btree.cpp31
-rw-r--r--src/mongo/db/btreecursor.cpp14
-rw-r--r--src/mongo/db/client.cpp72
-rw-r--r--src/mongo/db/clientcursor.cpp24
-rw-r--r--src/mongo/db/cloner.cpp20
-rw-r--r--src/mongo/db/commands/distinct.cpp10
-rw-r--r--src/mongo/db/commands/mr.cpp1
-rw-r--r--src/mongo/db/compact.cpp1
-rw-r--r--src/mongo/db/curop.cpp27
-rw-r--r--src/mongo/db/curop.h44
-rw-r--r--src/mongo/db/cursor.cpp8
-rw-r--r--src/mongo/db/db.cpp1
-rw-r--r--src/mongo/db/dbcommands.cpp59
-rw-r--r--src/mongo/db/dbcommands_admin.cpp30
-rw-r--r--src/mongo/db/dur_recover.cpp51
-rw-r--r--src/mongo/db/dur_recover.h9
-rw-r--r--src/mongo/db/extsort.cpp19
-rw-r--r--src/mongo/db/index_update.cpp1
-rw-r--r--src/mongo/db/instance.cpp61
-rwxr-xr-xsrc/mongo/db/interrupt_status_mongod.cpp6
-rw-r--r--src/mongo/db/kill_current_op.cpp88
-rw-r--r--src/mongo/db/kill_current_op.h54
-rw-r--r--src/mongo/db/pdfile.cpp53
-rw-r--r--src/mongo/s/d_migrate.cpp1
-rw-r--r--src/mongo/util/touch_pages.cpp1
26 files changed, 394 insertions, 293 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index 77bfaa4546d..2a4af75d4d0 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -235,6 +235,7 @@ if has_option( "asio" ):
# mongod files - also files used in tools. present in dbtests, but not in mongos and not in client libs.
serverOnlyFiles = [ "db/curop.cpp",
+ "db/kill_current_op.cpp",
"db/memconcept.cpp",
"db/interrupt_status_mongod.cpp",
"db/d_globals.cpp",
diff --git a/src/mongo/db/btree.cpp b/src/mongo/db/btree.cpp
index ae29ee3f7bd..56b0719d677 100644
--- a/src/mongo/db/btree.cpp
+++ b/src/mongo/db/btree.cpp
@@ -16,21 +16,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "pch.h"
-#include "db.h"
-#include "btree.h"
-#include "index_insertion_continuation.h"
-#include "pdfile.h"
-#include "json.h"
-#include "clientcursor.h"
-#include "client.h"
-#include "dbhelpers.h"
-#include "curop-inl.h"
-#include "stats/counters.h"
-#include "dur_commitjob.h"
-#include "btreebuilder.h"
+#include "mongo/pch.h"
+
+#include "mongo/db/btree.h"
+
+#include "mongo/db/btreebuilder.h"
+#include "mongo/db/client.h"
+#include "mongo/db/clientcursor.h"
+#include "mongo/db/curop-inl.h"
+#include "mongo/db/db.h"
+#include "mongo/db/dbhelpers.h"
+#include "mongo/db/dur_commitjob.h"
+#include "mongo/db/index_insertion_continuation.h"
+#include "mongo/db/json.h"
+#include "mongo/db/kill_current_op.h"
+#include "mongo/db/pdfile.h"
+#include "mongo/db/stats/counters.h"
+#include "mongo/server.h"
#include "mongo/util/startup_test.h"
-#include "../server.h"
namespace mongo {
diff --git a/src/mongo/db/btreecursor.cpp b/src/mongo/db/btreecursor.cpp
index 870282f4f20..add55f51ed5 100644
--- a/src/mongo/db/btreecursor.cpp
+++ b/src/mongo/db/btreecursor.cpp
@@ -16,12 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "pch.h"
-#include "btree.h"
-#include "pdfile.h"
-#include "jsobj.h"
-#include "curop-inl.h"
-#include "queryutil.h"
+#include "mongo/pch.h"
+
+#include "mongo/db/btree.h"
+#include "mongo/db/curop-inl.h"
+#include "mongo/db/jsobj.h"
+#include "mongo/db/kill_current_op.h"
+#include "mongo/db/pdfile.h"
+#include "mongo/db/queryutil.h"
namespace mongo {
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp
index 6109491aa8d..0cb7a2b1fbf 100644
--- a/src/mongo/db/client.cpp
+++ b/src/mongo/db/client.cpp
@@ -20,22 +20,25 @@
to an open socket (or logical connection if pooling on sockets) from a client.
*/
-#include "pch.h"
-#include "db.h"
-#include "client.h"
-#include "curop-inl.h"
-#include "json.h"
-#include "security.h"
-#include "commands.h"
-#include "instance.h"
-#include "../s/d_logic.h"
-#include "dbwebserver.h"
-#include "../util/mongoutils/html.h"
-#include "../util/mongoutils/checksum.h"
-#include "../util/file_allocator.h"
-#include "repl/rs.h"
-#include "../scripting/engine.h"
-#include "pagefault.h"
+#include "mongo/pch.h"
+
+#include "mongo/db/client.h"
+
+#include "mongo/db/db.h"
+#include "mongo/db/commands.h"
+#include "mongo/db/curop-inl.h"
+#include "mongo/db/kill_current_op.h"
+#include "mongo/db/dbwebserver.h"
+#include "mongo/db/instance.h"
+#include "mongo/db/json.h"
+#include "mongo/db/pagefault.h"
+#include "mongo/db/repl/rs.h"
+#include "mongo/s/d_logic.h"
+#include "mongo/scripting/engine.h"
+#include "mongo/db/security.h"
+#include "mongo/util/file_allocator.h"
+#include "mongo/util/mongoutils/checksum.h"
+#include "mongo/util/mongoutils/html.h"
namespace mongo {
@@ -386,43 +389,6 @@ namespace mongo {
return c->toString();
}
- void KillCurrentOp::interruptJs( AtomicUInt *op ) {
- if ( !globalScriptEngine )
- return;
- if ( !op ) {
- globalScriptEngine->interruptAll();
- }
- else {
- globalScriptEngine->interrupt( *op );
- }
- }
-
- void KillCurrentOp::killAll() {
- _globalKill = true;
- interruptJs( 0 );
- }
-
- void KillCurrentOp::kill(AtomicUInt i) {
- bool found = false;
- {
- scoped_lock l( Client::clientsMutex );
- for( set< Client* >::const_iterator j = Client::clients.begin(); !found && j != Client::clients.end(); ++j ) {
- for( CurOp *k = ( *j )->curop(); !found && k; k = k->parent() ) {
- if ( k->opNum() == i ) {
- k->kill();
- for( CurOp *l = ( *j )->curop(); l != k; l = l->parent() ) {
- l->kill();
- }
- found = true;
- }
- }
- }
- }
- if ( found ) {
- interruptJs( &i );
- }
- }
-
void Client::gotHandshake( const BSONObj& o ) {
BSONObjIterator i(o);
diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp
index d211a159183..8d002038fd1 100644
--- a/src/mongo/db/clientcursor.cpp
+++ b/src/mongo/db/clientcursor.cpp
@@ -22,19 +22,23 @@
Cursor -- and its derived classes -- are our internal cursors.
*/
-#include "pch.h"
-#include "clientcursor.h"
-#include "introspect.h"
+#include "mongo/pch.h"
+
+#include "mongo/db/clientcursor.h"
+
#include <time.h>
-#include "db.h"
-#include "commands.h"
-#include "repl_block.h"
-#include "../util/processinfo.h"
-#include "../util/timer.h"
+
#include "mongo/client/dbclientinterface.h"
-#include "mongo/db/scanandorder.h"
-#include "pagefault.h"
+#include "mongo/db/commands.h"
+#include "mongo/db/db.h"
+#include "mongo/db/introspect.h"
+#include "mongo/db/kill_current_op.h"
+#include "mongo/db/pagefault.h"
#include "mongo/db/repl/rs.h"
+#include "mongo/db/repl_block.h"
+#include "mongo/db/scanandorder.h"
+#include "mongo/util/processinfo.h"
+#include "mongo/util/timer.h"
namespace mongo {
diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp
index 8ca08303d85..b63f4f2771c 100644
--- a/src/mongo/db/cloner.cpp
+++ b/src/mongo/db/cloner.cpp
@@ -16,15 +16,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "pch.h"
-#include "cloner.h"
-#include "pdfile.h"
-#include "../bson/util/builder.h"
-#include "jsobj.h"
-#include "commands.h"
-#include "db.h"
-#include "instance.h"
-#include "repl.h"
+#include "mongo/pch.h"
+
+#include "mongo/db/cloner.h"
+#include "mongo/bson/util/builder.h"
+#include "mongo/db/commands.h"
+#include "mongo/db/db.h"
+#include "mongo/db/instance.h"
+#include "mongo/db/jsobj.h"
+#include "mongo/db/kill_current_op.h"
+#include "mongo/db/pdfile.h"
+#include "mongo/db/repl.h"
namespace mongo {
diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp
index 08c78308b35..664122101c7 100644
--- a/src/mongo/db/commands/distinct.cpp
+++ b/src/mongo/db/commands/distinct.cpp
@@ -15,11 +15,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-//#include "pch.h"
-#include "../commands.h"
-#include "../instance.h"
-#include "../clientcursor.h"
-#include "../../util/timer.h"
+#include "mongo/db/clientcursor.h"
+#include "mongo/db/commands.h"
+#include "mongo/db/instance.h"
+#include "mongo/db/kill_current_op.h"
+#include "mongo/util/timer.h"
namespace mongo {
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index 7f69a847398..21272f384d6 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -28,6 +28,7 @@
#include "../../s/d_chunk_manager.h"
#include "../../s/d_logic.h"
#include "../../s/grid.h"
+#include "mongo/db/kill_current_op.h"
#include "mr.h"
diff --git a/src/mongo/db/compact.cpp b/src/mongo/db/compact.cpp
index 847a77b01e0..1650eac6573 100644
--- a/src/mongo/db/compact.cpp
+++ b/src/mongo/db/compact.cpp
@@ -29,6 +29,7 @@
#include "mongo/db/extsort.h"
#include "mongo/db/index.h"
#include "mongo/db/index_update.h"
+#include "mongo/db/kill_current_op.h"
#include "mongo/db/pdfile.h"
#include "mongo/util/concurrency/task.h"
#include "mongo/util/timer.h"
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp
index 4658150dbfa..c751531951b 100644
--- a/src/mongo/db/curop.cpp
+++ b/src/mongo/db/curop.cpp
@@ -14,9 +14,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "pch.h"
-#include "curop.h"
-#include "database.h"
+#include "mongo/pch.h"
+
+#include "mongo/db/curop.h"
+#include "mongo/db/database.h"
namespace mongo {
@@ -181,26 +182,6 @@ namespace mongo {
return b.obj();
}
- void KillCurrentOp::checkForInterrupt( bool heedMutex ) {
- Client& c = cc();
- if ( heedMutex && Lock::somethingWriteLocked() && c.hasWrittenThisPass() )
- return;
- if( _globalKill )
- uasserted(11600,"interrupted at shutdown");
- if( c.curop()->killed() ) {
- uasserted(11601,"operation was interrupted");
- }
- }
-
- const char * KillCurrentOp::checkForInterruptNoAssert() {
- Client& c = cc();
- if( _globalKill )
- return "interrupted at shutdown";
- if( c.curop()->killed() )
- return "interrupted";
- return "";
- }
-
AtomicUInt CurOp::_nextOpNum;
diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h
index 0273954dd7d..fc6531a83d5 100644
--- a/src/mongo/db/curop.h
+++ b/src/mongo/db/curop.h
@@ -19,13 +19,15 @@
#pragma once
-#include "namespace-inl.h"
-#include "client.h"
-#include "../bson/util/atomic_int.h"
-#include "../util/concurrency/spin_lock.h"
-#include "../util/time_support.h"
-#include "../util/net/hostandport.h"
-#include "../util/progress_meter.h"
+#include <vector>
+
+#include "mongo/bson/util/atomic_int.h"
+#include "mongo/db/client.h"
+#include "mongo/db/namespace-inl.h"
+#include "mongo/util/concurrency/spin_lock.h"
+#include "mongo/util/net/hostandport.h"
+#include "mongo/util/progress_meter.h"
+#include "mongo/util/time_support.h"
namespace mongo {
@@ -264,33 +266,5 @@ namespace mongo {
// so this should be 30000 in that case
long long _expectedLatencyMs;
-
};
-
- /* _globalKill: we are shutting down
- otherwise kill attribute set on specified CurOp
- this class does not handle races between interruptJs and the checkForInterrupt functions - those must be
- handled by the client of this class
- */
- extern class KillCurrentOp {
- public:
- void killAll();
- void kill(AtomicUInt i);
-
- /** @return true if global interrupt and should terminate the operation */
- bool globalInterruptCheck() const { return _globalKill; }
-
- /**
- * @param heedMutex if true and have a write lock, won't kill op since it might be unsafe
- */
- void checkForInterrupt( bool heedMutex = true );
-
- /** @return "" if not interrupted. otherwise, you should stop. */
- const char *checkForInterruptNoAssert();
-
- private:
- void interruptJs( AtomicUInt *op );
- volatile bool _globalKill;
- } killCurrentOp;
-
}
diff --git a/src/mongo/db/cursor.cpp b/src/mongo/db/cursor.cpp
index af617f36fad..1ce5da1b36a 100644
--- a/src/mongo/db/cursor.cpp
+++ b/src/mongo/db/cursor.cpp
@@ -14,9 +14,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "pch.h"
-#include "pdfile.h"
-#include "curop-inl.h"
+#include "mongo/pch.h"
+
+#include "mongo/db/curop-inl.h"
+#include "mongo/db/kill_current_op.h"
+#include "mongo/db/pdfile.h"
namespace mongo {
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index e1b514983f0..6225a437e7c 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/instance.h"
#include "mongo/db/introspect.h"
#include "mongo/db/json.h"
+#include "mongo/db/kill_current_op.h"
#include "mongo/db/module.h"
#include "mongo/db/pdfile.h"
#include "mongo/db/repl.h"
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp
index 6c1db1b20f7..6000654c76c 100644
--- a/src/mongo/db/dbcommands.cpp
+++ b/src/mongo/db/dbcommands.cpp
@@ -20,37 +20,40 @@
See s/commnands_public.cpp for mongos.
*/
-#include "pch.h"
-#include "ops/count.h"
-#include "pdfile.h"
-#include "jsobj.h"
-#include "../bson/util/builder.h"
+#include "mongo/pch.h"
+
#include <time.h>
-#include "introspect.h"
-#include "btree.h"
-#include "../util/lruishmap.h"
-#include "../util/md5.hpp"
-#include "../util/processinfo.h"
-#include "../util/ramlog.h"
-#include "json.h"
-#include "repl.h"
-#include "repl_block.h"
-#include "replutil.h"
-#include "commands.h"
-#include "db.h"
-#include "instance.h"
-#include "lasterror.h"
-#include "security.h"
-#include "queryoptimizer.h"
-#include "../scripting/engine.h"
-#include "stats/counters.h"
-#include "background.h"
-#include "../util/version.h"
-#include "../s/d_writeback.h"
-#include "dur_stats.h"
-#include "../server.h"
+
+#include "mongo/bson/util/builder.h"
+#include "mongo/db/background.h"
+#include "mongo/db/btree.h"
+#include "mongo/db/commands.h"
+#include "mongo/db/db.h"
+#include "mongo/db/dur_stats.h"
#include "mongo/db/index_update.h"
+#include "mongo/db/instance.h"
+#include "mongo/db/introspect.h"
+#include "mongo/db/jsobj.h"
+#include "mongo/db/json.h"
+#include "mongo/db/kill_current_op.h"
+#include "mongo/db/lasterror.h"
+#include "mongo/db/ops/count.h"
+#include "mongo/db/pdfile.h"
+#include "mongo/db/queryoptimizer.h"
+#include "mongo/db/repl.h"
#include "mongo/db/repl/bgsync.h"
+#include "mongo/db/repl_block.h"
+#include "mongo/db/replutil.h"
+#include "mongo/db/security.h"
+#include "mongo/db/stats/counters.h"
+#include "mongo/s/d_writeback.h"
+#include "mongo/scripting/engine.h"
+#include "mongo/server.h"
+#include "mongo/util/lruishmap.h"
+#include "mongo/util/md5.hpp"
+#include "mongo/util/processinfo.h"
+#include "mongo/util/ramlog.h"
+#include "mongo/util/version.h"
namespace mongo {
diff --git a/src/mongo/db/dbcommands_admin.cpp b/src/mongo/db/dbcommands_admin.cpp
index 8077c3ab79f..ee71017fcc9 100644
--- a/src/mongo/db/dbcommands_admin.cpp
+++ b/src/mongo/db/dbcommands_admin.cpp
@@ -22,24 +22,26 @@
*/
-#include "pch.h"
-#include "jsobj.h"
-#include "pdfile.h"
-#include "namespace-inl.h"
-#include "commands.h"
-#include "cmdline.h"
-#include "btree.h"
-#include "curop-inl.h"
-#include "../util/background.h"
-#include "../util/logfile.h"
-#include "../util/alignedbuilder.h"
-#include "../util/paths.h"
-#include "../scripting/engine.h"
-#include "../util/timer.h"
+#include "mongo/pch.h"
#include <boost/filesystem/convenience.hpp>
#include <boost/filesystem/operations.hpp>
+#include "mongo/db/btree.h"
+#include "mongo/db/cmdline.h"
+#include "mongo/db/commands.h"
+#include "mongo/db/curop-inl.h"
+#include "mongo/db/jsobj.h"
+#include "mongo/db/kill_current_op.h"
+#include "mongo/db/namespace-inl.h"
+#include "mongo/db/pdfile.h"
+#include "mongo/scripting/engine.h"
+#include "mongo/util/alignedbuilder.h"
+#include "mongo/util/background.h"
+#include "mongo/util/logfile.h"
+#include "mongo/util/paths.h"
+#include "mongo/util/timer.h"
+
namespace mongo {
class CleanCmd : public Command {
diff --git a/src/mongo/db/dur_recover.cpp b/src/mongo/db/dur_recover.cpp
index eae80f41016..c860d195b0c 100644
--- a/src/mongo/db/dur_recover.cpp
+++ b/src/mongo/db/dur_recover.cpp
@@ -16,31 +16,34 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "pch.h"
-
-#include "dur.h"
-#include "dur_stats.h"
-#include "dur_recover.h"
-#include "dur_journal.h"
-#include "dur_journalformat.h"
-#include "durop.h"
-#include "namespace.h"
-#include "../util/mongoutils/str.h"
-#include "../util/bufreader.h"
-#include "../util/concurrency/race.h"
-#include "pdfile.h"
-#include "database.h"
-#include "db.h"
-#include "../util/startup_test.h"
-#include "../util/checksum.h"
-#include "cmdline.h"
-#include "curop.h"
-#include "mongommf.h"
-#include "../util/compress.h"
-#include <sys/stat.h>
-#include <fcntl.h>
-#include "dur_commitjob.h"
+#include "mongo/pch.h"
+
+#include "mongo/db/dur_recover.h"
+
#include <boost/filesystem/operations.hpp>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#include "mongo/db/cmdline.h"
+#include "mongo/db/curop.h"
+#include "mongo/db/database.h"
+#include "mongo/db/db.h"
+#include "mongo/db/dur.h"
+#include "mongo/db/dur_commitjob.h"
+#include "mongo/db/dur_journal.h"
+#include "mongo/db/dur_journalformat.h"
+#include "mongo/db/dur_stats.h"
+#include "mongo/db/durop.h"
+#include "mongo/db/kill_current_op.h"
+#include "mongo/db/mongommf.h"
+#include "mongo/db/namespace.h"
+#include "mongo/db/pdfile.h"
+#include "mongo/util/bufreader.h"
+#include "mongo/util/checksum.h"
+#include "mongo/util/compress.h"
+#include "mongo/util/concurrency/race.h"
+#include "mongo/util/mongoutils/str.h"
+#include "mongo/util/startup_test.h"
using namespace mongoutils;
diff --git a/src/mongo/db/dur_recover.h b/src/mongo/db/dur_recover.h
index 2f54b0af8f3..a255e11be6b 100644
--- a/src/mongo/db/dur_recover.h
+++ b/src/mongo/db/dur_recover.h
@@ -2,9 +2,12 @@
#pragma once
-#include "dur_journalformat.h"
-#include "../util/concurrency/mutex.h"
-#include "../util/file.h"
+#include <boost/filesystem/operations.hpp>
+#include <list>
+
+#include "mongo/db/dur_journalformat.h"
+#include "mongo/util/concurrency/mutex.h"
+#include "mongo/util/file.h"
namespace mongo {
class MongoMMF;
diff --git a/src/mongo/db/extsort.cpp b/src/mongo/db/extsort.cpp
index 4629873f4e6..489dbaa959c 100644
--- a/src/mongo/db/extsort.cpp
+++ b/src/mongo/db/extsort.cpp
@@ -16,23 +16,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "pch.h"
+#include "mongo/pch.h"
+
+#include "mongo/db/extsort.h"
#if defined(_WIN32)
# include <io.h>
#endif
-#include "extsort.h"
-#include "namespace-inl.h"
-#include "../util/file.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <fstream>
#include <boost/filesystem/convenience.hpp>
#include <boost/filesystem/operations.hpp>
+#include <fcntl.h>
+#include <fstream>
+#include <sys/stat.h>
+#include <sys/types.h>
-
+#include "mongo/db/kill_current_op.h"
+#include "mongo/db/namespace-inl.h"
+#include "mongo/util/file.h"
namespace mongo {
diff --git a/src/mongo/db/index_update.cpp b/src/mongo/db/index_update.cpp
index b40c69e37ef..c062d89ebb5 100644
--- a/src/mongo/db/index_update.cpp
+++ b/src/mongo/db/index_update.cpp
@@ -25,6 +25,7 @@
#include "mongo/db/compact.h"
#include "mongo/db/extsort.h"
#include "mongo/db/index.h"
+#include "mongo/db/kill_current_op.h"
#include "mongo/db/namespace_details.h"
#include "mongo/db/pdfile_private.h"
#include "mongo/db/replutil.h"
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index 6df5c8c21ed..233c7a2cc38 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -16,42 +16,43 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "pch.h"
+#include "mongo/pch.h"
#include <boost/thread/thread.hpp>
-
-#include "../util/time_support.h"
-#include "db.h"
-#include "../bson/util/atomic_int.h"
-#include "introspect.h"
-#include "repl.h"
-#include "dbmessage.h"
-#include "instance.h"
-#include "lasterror.h"
-#include "security.h"
-#include "json.h"
-#include "replutil.h"
-#include "../s/d_logic.h"
-#include "../util/file_allocator.h"
-#include "../util/goodies.h"
-#include "cmdline.h"
+#include <fstream>
+#include <boost/filesystem/operations.hpp>
#if !defined(_WIN32)
#include <sys/file.h>
#endif
-#include "stats/counters.h"
-#include "background.h"
-#include "dur_journal.h"
-#include "dur_recover.h"
-#include "d_concurrency.h"
-#include "ops/count.h"
-#include "ops/delete.h"
-#include "ops/query.h"
-#include "ops/update.h"
-#include "pagefault.h"
-#include <fstream>
-#include <boost/filesystem/operations.hpp>
-#include "dur_commitjob.h"
+
+#include "mongo/util/time_support.h"
+#include "mongo/bson/util/atomic_int.h"
+#include "mongo/db/background.h"
+#include "mongo/db/cmdline.h"
#include "mongo/db/commands/fsync.h"
+#include "mongo/db/d_concurrency.h"
+#include "mongo/db/db.h"
+#include "mongo/db/dbmessage.h"
+#include "mongo/db/dur_commitjob.h"
+#include "mongo/db/dur_journal.h"
+#include "mongo/db/dur_recover.h"
+#include "mongo/db/instance.h"
+#include "mongo/db/introspect.h"
+#include "mongo/db/json.h"
+#include "mongo/db/kill_current_op.h"
+#include "mongo/db/lasterror.h"
+#include "mongo/db/ops/count.h"
+#include "mongo/db/ops/delete.h"
+#include "mongo/db/ops/query.h"
+#include "mongo/db/ops/update.h"
+#include "mongo/db/pagefault.h"
+#include "mongo/db/repl.h"
+#include "mongo/db/replutil.h"
+#include "mongo/db/security.h"
+#include "mongo/db/stats/counters.h"
+#include "mongo/s/d_logic.h"
+#include "mongo/util/file_allocator.h"
+#include "mongo/util/goodies.h"
namespace mongo {
diff --git a/src/mongo/db/interrupt_status_mongod.cpp b/src/mongo/db/interrupt_status_mongod.cpp
index ab66d3c3a14..915a183651c 100755
--- a/src/mongo/db/interrupt_status_mongod.cpp
+++ b/src/mongo/db/interrupt_status_mongod.cpp
@@ -16,8 +16,10 @@
#include "pch.h"
-#include "db/interrupt_status_mongod.h"
-#include "db/curop.h"
+#include "mongo/db/interrupt_status_mongod.h"
+
+#include "mongo/db/curop.h"
+#include "mongo/db/kill_current_op.h"
namespace mongo {
diff --git a/src/mongo/db/kill_current_op.cpp b/src/mongo/db/kill_current_op.cpp
new file mode 100644
index 00000000000..17d0a6248d7
--- /dev/null
+++ b/src/mongo/db/kill_current_op.cpp
@@ -0,0 +1,88 @@
+/**
+* Copyright (C) 2009 10gen Inc.
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License, version 3,
+* as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "mongo/db/kill_current_op.h"
+
+#include <set>
+
+#include "mongo/bson/util/atomic_int.h"
+#include "mongo/db/client.h"
+#include "mongo/db/curop.h"
+#include "mongo/scripting/engine.h"
+
+namespace mongo {
+
+ void KillCurrentOp::interruptJs( AtomicUInt *op ) {
+ if ( !globalScriptEngine )
+ return;
+ if ( !op ) {
+ globalScriptEngine->interruptAll();
+ }
+ else {
+ globalScriptEngine->interrupt( *op );
+ }
+ }
+
+ void KillCurrentOp::killAll() {
+ _globalKill = true;
+ interruptJs( 0 );
+ }
+
+ void KillCurrentOp::kill(AtomicUInt i) {
+ bool found = false;
+ {
+ scoped_lock l( Client::clientsMutex );
+ for( set< Client* >::const_iterator j = Client::clients.begin(); !found && j != Client::clients.end(); ++j ) {
+ for( CurOp *k = ( *j )->curop(); !found && k; k = k->parent() ) {
+ if ( k->opNum() == i ) {
+ k->kill();
+ for( CurOp *l = ( *j )->curop(); l != k; l = l->parent() ) {
+ l->kill();
+ }
+ found = true;
+ }
+ }
+ }
+ }
+ if ( found ) {
+ interruptJs( &i );
+ }
+ }
+
+ void KillCurrentOp::checkForInterrupt( bool heedMutex ) {
+ Client& c = cc();
+ if ( heedMutex && Lock::somethingWriteLocked() && c.hasWrittenThisPass() )
+ return;
+ if( _globalKill )
+ uasserted(11600,"interrupted at shutdown");
+ if( c.curop()->killed() ) {
+ uasserted(11601,"operation was interrupted");
+ }
+ }
+
+ const char * KillCurrentOp::checkForInterruptNoAssert() {
+ Client& c = cc();
+ if( _globalKill )
+ return "interrupted at shutdown";
+ if( c.curop()->killed() )
+ return "interrupted";
+ return "";
+ }
+
+
+
+
+}
diff --git a/src/mongo/db/kill_current_op.h b/src/mongo/db/kill_current_op.h
new file mode 100644
index 00000000000..302b1d7b77b
--- /dev/null
+++ b/src/mongo/db/kill_current_op.h
@@ -0,0 +1,54 @@
+
+/*
+ * Copyright (C) 2010 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#pragma once
+
+#include <boost/thread/condition.hpp>
+#include <boost/thread/mutex.hpp>
+
+#include "mongo/bson/util/atomic_int.h"
+
+namespace mongo {
+
+ /* _globalKill: we are shutting down
+ otherwise kill attribute set on specified CurOp
+ this class does not handle races between interruptJs and the checkForInterrupt functions - those must be
+ handled by the client of this class
+ */
+ extern class KillCurrentOp {
+ public:
+ void killAll();
+ void kill(AtomicUInt i);
+
+ /** @return true if global interrupt and should terminate the operation */
+ bool globalInterruptCheck() const { return _globalKill; }
+
+ /**
+ * @param heedMutex if true and have a write lock, won't kill op since it might be unsafe
+ */
+ void checkForInterrupt( bool heedMutex = true );
+
+ /** @return "" if not interrupted. otherwise, you should stop. */
+ const char *checkForInterruptNoAssert();
+
+ private:
+ void interruptJs( AtomicUInt *op );
+ volatile bool _globalKill;
+ } killCurrentOp;
+
+}
diff --git a/src/mongo/db/pdfile.cpp b/src/mongo/db/pdfile.cpp
index f974a201088..610c7c554ef 100644
--- a/src/mongo/db/pdfile.cpp
+++ b/src/mongo/db/pdfile.cpp
@@ -23,34 +23,37 @@ _ coalesce deleted
_ disallow system* manipulations from the database.
*/
-#include "pch.h"
-#include "pdfile.h"
-#include "mongo/db/pdfile_private.h"
-#include "db.h"
-#include "../util/mmap.h"
-#include "../util/hashtab.h"
-#include "../util/file_allocator.h"
-#include "../util/processinfo.h"
-#include "../util/file.h"
-#include "btree.h"
-#include "btreebuilder.h"
+#include "mongo/pch.h"
+
+#include "mongo/db/pdfile.h"
+
#include <algorithm>
+#include <boost/filesystem/operations.hpp>
#include <list>
-#include "repl.h"
-#include "dbhelpers.h"
-#include "namespace-inl.h"
-#include "extsort.h"
-#include "curop-inl.h"
-#include "background.h"
-#include "compact.h"
-#include "ops/delete.h"
-#include "instance.h"
-#include "replutil.h"
-#include "memconcept.h"
-#include "mongo/db/lasterror.h"
-#include "mongo/db/index_update.h"
-#include <boost/filesystem/operations.hpp>
+#include "mongo/db/pdfile_private.h"
+#include "mongo/db/background.h"
+#include "mongo/db/btree.h"
+#include "mongo/db/btreebuilder.h"
+#include "mongo/db/compact.h"
+#include "mongo/db/curop-inl.h"
+#include "mongo/db/db.h"
+#include "mongo/db/dbhelpers.h"
+#include "mongo/db/extsort.h"
+#include "mongo/db/index_update.h"
+#include "mongo/db/instance.h"
+#include "mongo/db/kill_current_op.h"
+#include "mongo/db/lasterror.h"
+#include "mongo/db/memconcept.h"
+#include "mongo/db/namespace-inl.h"
+#include "mongo/db/ops/delete.h"
+#include "mongo/db/repl.h"
+#include "mongo/db/replutil.h"
+#include "mongo/util/file.h"
+#include "mongo/util/file_allocator.h"
+#include "mongo/util/hashtab.h"
+#include "mongo/util/mmap.h"
+#include "mongo/util/processinfo.h"
namespace mongo {
diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp
index e64ee1f0130..d7e68b79d8b 100644
--- a/src/mongo/s/d_migrate.cpp
+++ b/src/mongo/s/d_migrate.cpp
@@ -40,6 +40,7 @@
#include "../db/clientcursor.h"
#include "../db/pagefault.h"
#include "../db/repl.h"
+#include "../db/kill_current_op.h"
#include "../client/connpool.h"
#include "../client/distlock.h"
diff --git a/src/mongo/util/touch_pages.cpp b/src/mongo/util/touch_pages.cpp
index 8f4e115e5e6..919ac58cbc8 100644
--- a/src/mongo/util/touch_pages.cpp
+++ b/src/mongo/util/touch_pages.cpp
@@ -23,6 +23,7 @@
#include <string>
#include "mongo/db/curop.h"
+#include "mongo/db/kill_current_op.h"
#include "mongo/db/pdfile.h"
#include "mongo/db/database.h"
#include "mongo/util/mmap.h"