Exemplo n.º 1
0
    bool GlobalEnvironmentMongoD::killOperation(AtomicUInt opId) {
        scoped_lock clientLock(Client::clientsMutex);
        bool found = false;

        // XXX clean up
        {
            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() != opId )
                        continue;

                    k->kill();
                    for( CurOp *l = ( *j )->curop(); l; l = l->parent() ) {
                        l->kill();
                    }

                    found = true;
                }
            }
        }
        if ( found ) {
            interruptJs( &opId );
        }
        return found;
    }
Exemplo n.º 2
0
    bool KillCurrentOp::_killImpl_inclientlock(AtomicUInt i, bool* pNotifyFlag /* = NULL */) {
        bool found = false;
        {
            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 )
                        continue;

                    k->kill(pNotifyFlag);
                    for( CurOp *l = ( *j )->curop(); l; l = l->parent() ) {
                        l->kill();
                    }

                    found = true;
                }
            }
        }
        if ( found ) {
            interruptJs( &i );
        }
        return found;
    }
Exemplo n.º 3
0
    Status OperationContextImpl::checkForInterruptNoAssert() const {
        if (getGlobalServiceContext()->getKillAllOperations()) {
            return Status(ErrorCodes::InterruptedAtShutdown, "interrupted at shutdown");
        }

        CurOp* curOp = CurOp::get(this);
        if (curOp->maxTimeHasExpired()) {
            curOp->kill();
            return Status(ErrorCodes::ExceededTimeLimit, "operation exceeded time limit");
        }

        MONGO_FAIL_POINT_BLOCK(checkForInterruptFail, scopedFailPoint) {
            if (opShouldFail(this, scopedFailPoint.getData())) {
                log() << "set pending kill on "
                      << (curOp->parent() ? "nested" : "top-level")
                      << " op " << curOp->opNum() << ", for checkForInterruptFail";
                curOp->kill();
            }
        }

        if (curOp->killPending()) {
            return Status(ErrorCodes::Interrupted, "operation was interrupted");
        }

        return Status::OK();
    }
Exemplo n.º 4
0
 std::vector<BSONObj> IndexBuilder::killMatchingIndexBuilds(const BSONObj& criteria) {
     verify(Lock::somethingWriteLocked());
     std::vector<BSONObj> indexes;
     CurOp* op = NULL;
     while ((op = CurOp::getOp(criteria)) != NULL) {
         BSONObj index = op->query();
         killCurrentOp.kill(op->opNum());
         indexes.push_back(index);
     }
     if (indexes.size() > 0) {
         log() << "halted " << indexes.size() << " index build(s)" << endl;
     }
     return indexes;
 }
Exemplo n.º 5
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 );
     }
 }
Exemplo n.º 6
0
    bool GlobalEnvironmentMongoD::_killOperationsAssociatedWithClientAndOpId_inlock(
            Client* client, unsigned int opId) {
        for( CurOp *k = client->curop(); k; k = k->parent() ) {
            if ( k->opNum() != opId )
                continue;

            k->kill();
            for( CurOp *l = client->curop(); l; l = l->parent() ) {
                l->kill();
            }

            for (size_t i = 0; i < _killOpListeners.size(); i++) {
                try {
                    _killOpListeners[i]->interrupt(opId);
                }
                catch (...) {
                    std::terminate();
                }
            }
            return true;
        }
        return false;
    }
Exemplo n.º 7
0
    bool GlobalEnvironmentMongoD::killOperation(unsigned int opId) {
        boost::mutex::scoped_lock clientLock(Client::clientsMutex);
        bool found = false;

        // XXX clean up
        {
            for(ClientSet::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() != opId )
                        continue;

                    k->kill();
                    for( CurOp *l = ( *j )->curop(); l; l = l->parent() ) {
                        l->kill();
                    }

                    found = true;
                }
            }
        }

        if (found) {
            for (size_t i = 0; i < _killOpListeners.size(); i++) {
                try {
                    _killOpListeners[i]->interrupt(opId);
                }
                catch (...) {
                    std::terminate();
                }
            }
        }
        return found;
    }