summaryrefslogtreecommitdiff
path: root/src/mongo/db/service_context_d.cpp
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2016-05-27 10:18:32 -0400
committerAndy Schwerin <schwerin@mongodb.com>2016-05-27 11:45:14 -0400
commita47b34136b9952865e060a6126fffc2a8a252d6d (patch)
treee0a41672c79a7f47512e3c96c93a60b404ebd61a /src/mongo/db/service_context_d.cpp
parent2ed62dcea1bb786fd166de499b3a9af72bebc41b (diff)
downloadmongo-a47b34136b9952865e060a6126fffc2a8a252d6d.tar.gz
SERVER-23905 Move global operation killing implementations from ServiceContextMongoD to ServiceContext.
Diffstat (limited to 'src/mongo/db/service_context_d.cpp')
-rw-r--r--src/mongo/db/service_context_d.cpp74
1 files changed, 2 insertions, 72 deletions
diff --git a/src/mongo/db/service_context_d.cpp b/src/mongo/db/service_context_d.cpp
index b82f89c4c05..aac7296a5a4 100644
--- a/src/mongo/db/service_context_d.cpp
+++ b/src/mongo/db/service_context_d.cpp
@@ -66,9 +66,9 @@ MONGO_INITIALIZER(SetGlobalEnvironment)(InitializerContext* context) {
return Status::OK();
}
-ServiceContextMongoD::ServiceContextMongoD() : _globalKill(false), _storageEngine(NULL) {}
+ServiceContextMongoD::ServiceContextMongoD() = default;
-ServiceContextMongoD::~ServiceContextMongoD() {}
+ServiceContextMongoD::~ServiceContextMongoD() = default;
StorageEngine* ServiceContextMongoD::getGlobalStorageEngine() {
// We don't check that globalStorageEngine is not-NULL here intentionally. We can encounter
@@ -252,76 +252,6 @@ const StorageEngine::Factory* StorageFactoriesIteratorMongoD::next() {
return _curr++->second;
}
-void ServiceContextMongoD::setKillAllOperations() {
- stdx::lock_guard<stdx::mutex> clientLock(_mutex);
- _globalKill = true;
- for (const auto listener : _killOpListeners) {
- try {
- listener->interruptAll();
- } catch (...) {
- std::terminate();
- }
- }
-}
-
-bool ServiceContextMongoD::getKillAllOperations() {
- return _globalKill;
-}
-
-void ServiceContextMongoD::_killOperation_inlock(OperationContext* opCtx,
- ErrorCodes::Error killCode) {
- opCtx->markKilled(killCode);
-
- for (const auto listener : _killOpListeners) {
- try {
- listener->interrupt(opCtx->getOpID());
- } catch (...) {
- std::terminate();
- }
- }
-}
-
-bool ServiceContextMongoD::killOperation(unsigned int opId) {
- for (LockedClientsCursor cursor(this); Client* client = cursor.next();) {
- stdx::lock_guard<Client> lk(*client);
-
- OperationContext* opCtx = client->getOperationContext();
- if (opCtx && opCtx->getOpID() == opId) {
- _killOperation_inlock(opCtx, ErrorCodes::Interrupted);
- return true;
- }
- }
-
- return false;
-}
-
-void ServiceContextMongoD::killAllUserOperations(const OperationContext* txn,
- ErrorCodes::Error killCode) {
- for (LockedClientsCursor cursor(this); Client* client = cursor.next();) {
- if (!client->isFromUserConnection()) {
- // Don't kill system operations.
- continue;
- }
-
- stdx::lock_guard<Client> lk(*client);
- OperationContext* toKill = client->getOperationContext();
-
- // Don't kill ourself.
- if (toKill && toKill->getOpID() != txn->getOpID()) {
- _killOperation_inlock(toKill, killCode);
- }
- }
-}
-
-void ServiceContextMongoD::unsetKillAllOperations() {
- _globalKill = false;
-}
-
-void ServiceContextMongoD::registerKillOpListener(KillOpListenerInterface* listener) {
- stdx::lock_guard<stdx::mutex> clientLock(_mutex);
- _killOpListeners.push_back(listener);
-}
-
std::unique_ptr<OperationContext> ServiceContextMongoD::_newOpCtx(Client* client) {
invariant(&cc() == client);
return std::unique_ptr<OperationContextImpl>(new OperationContextImpl());