diff options
author | Spencer T Brody <spencer@mongodb.com> | 2015-05-29 18:14:03 -0400 |
---|---|---|
committer | Spencer T Brody <spencer@mongodb.com> | 2015-05-29 18:14:03 -0400 |
commit | 993fc5e4ed9264965f16a948d3732d3fc55d1255 (patch) | |
tree | d5288061d1d0e10bc499e37d728c40ce83bcb06f /src/mongo/db/service_context_d.cpp | |
parent | e181ea38af737ef7aaf5f8228f870d8c7149b2bb (diff) | |
download | mongo-993fc5e4ed9264965f16a948d3732d3fc55d1255.tar.gz |
Revert "SERVER-18277 Clarify locking of Client when accessing its stored OperationContext."
This reverts commit 5c2d133871b2ad2adf6c617364d036ca25261f2d.
Diffstat (limited to 'src/mongo/db/service_context_d.cpp')
-rw-r--r-- | src/mongo/db/service_context_d.cpp | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/src/mongo/db/service_context_d.cpp b/src/mongo/db/service_context_d.cpp index eb00449c625..eaef2f6f639 100644 --- a/src/mongo/db/service_context_d.cpp +++ b/src/mongo/db/service_context_d.cpp @@ -205,11 +205,11 @@ namespace mongo { } void ServiceContextMongoD::setKillAllOperations() { - stdx::lock_guard<stdx::mutex> clientLock(_mutex); + boost::lock_guard<boost::mutex> clientLock(_mutex); _globalKill = true; - for (const auto listener : _killOpListeners) { + for (size_t i = 0; i < _killOpListeners.size(); i++) { try { - listener->interruptAll(); + _killOpListeners[i]->interruptAll(); } catch (...) { std::terminate(); @@ -223,38 +223,30 @@ namespace mongo { bool ServiceContextMongoD::_killOperationsAssociatedWithClientAndOpId_inlock( Client* client, unsigned int opId) { - OperationContext* opCtx = client->getOperationContext(); - if (!opCtx) { - return false; - } - for( CurOp *k = CurOp::get(opCtx); k; k = k->parent() ) { + for( CurOp *k = CurOp::getFromClient(client); k; k = k->parent() ) { if ( k->opNum() != opId ) continue; - _killOperation_inlock(opCtx); - return true; - } - return false; - } - - void ServiceContextMongoD::_killOperation_inlock(OperationContext* opCtx) { - for(CurOp *l = CurOp::get(opCtx); l; l = l->parent()) { - l->kill(); - } - - for (const auto listener : _killOpListeners) { - try { - listener->interrupt(opCtx->getOpID()); + k->kill(); + for( CurOp *l = CurOp::getFromClient(client); l; l = l->parent() ) { + l->kill(); } - catch (...) { - std::terminate(); + + for (size_t i = 0; i < _killOpListeners.size(); i++) { + try { + _killOpListeners[i]->interrupt(opId); + } + catch (...) { + std::terminate(); + } } + return true; } + return false; } bool ServiceContextMongoD::killOperation(unsigned int opId) { for (LockedClientsCursor cursor(this); Client* client = cursor.next();) { - stdx::lock_guard<Client> lk(*client); bool found = _killOperationsAssociatedWithClientAndOpId_inlock(client, opId); if (found) { return true; @@ -271,18 +263,17 @@ namespace mongo { continue; } - stdx::lock_guard<Client> lk(*client); - OperationContext* toKill = client->getOperationContext(); - if (!toKill) { - continue; - } - - if (toKill->getOpID() == txn->getOpID()) { + if (CurOp::getFromClient(client)->opNum() == txn->getOpID()) { // Don't kill ourself. continue; } - _killOperation_inlock(toKill); + bool found = _killOperationsAssociatedWithClientAndOpId_inlock( + client, CurOp::getFromClient(client)->opNum()); + if (!found) { + warning() << "Attempted to kill operation " << CurOp::getFromClient(client)->opNum() + << " but the opId changed"; + } } } @@ -291,7 +282,7 @@ namespace mongo { } void ServiceContextMongoD::registerKillOpListener(KillOpListenerInterface* listener) { - stdx::lock_guard<stdx::mutex> clientLock(_mutex); + boost::lock_guard<boost::mutex> clientLock(_mutex); _killOpListeners.push_back(listener); } |