Exemple #1
0
Session* OperationContextSession::get(OperationContext* opCtx) {
    auto& operationSession = operationSessionDecoration(opCtx);
    if (operationSession) {
        return operationSession->get();
    }

    return nullptr;
}
Exemple #2
0
Session* OperationContextSession::get(OperationContext* opCtx) {
    auto& checkedOutSession = operationSessionDecoration(opCtx);
    if (checkedOutSession) {
        return checkedOutSession->scopedSession.get();
    }

    return nullptr;
}
Exemple #3
0
OperationContextSession::~OperationContextSession() {
    auto& checkedOutSession = operationSessionDecoration(_opCtx);
    if (checkedOutSession) {
        invariant(checkedOutSession->checkOutNestingLevel > 0);
        if (--checkedOutSession->checkOutNestingLevel == 0) {
            checkedOutSession.reset();
        }
    }
}
Exemple #4
0
OperationContextSession::OperationContextSession(OperationContext* opCtx) : _opCtx(opCtx) {
    if (!opCtx->getLogicalSessionId()) {
        return;
    }

    auto sessionTransactionTable = SessionCatalog::get(opCtx);

    auto& operationSession = operationSessionDecoration(opCtx);
    operationSession.emplace(sessionTransactionTable->checkOutSession(opCtx));
}
Exemple #5
0
OperationContextSession::OperationContextSession(OperationContext* opCtx) : _opCtx(opCtx) {
    if (!opCtx->getLogicalSessionId()) {
        return;
    }

    auto& checkedOutSession = operationSessionDecoration(opCtx);
    if (!checkedOutSession) {
        auto sessionTransactionTable = SessionCatalog::get(opCtx);
        checkedOutSession.emplace(sessionTransactionTable->checkOutSession(opCtx));
    }

    const auto session = checkedOutSession->scopedSession.get();
    invariant(opCtx->getLogicalSessionId() == session->getSessionId());

    checkedOutSession->checkOutNestingLevel++;

    if (checkedOutSession->checkOutNestingLevel > 1) {
        return;
    }

    if (opCtx->getTxnNumber()) {
        checkedOutSession->scopedSession->begin(opCtx, opCtx->getTxnNumber().get());
    }
}
Exemple #6
0
OperationContextSession::~OperationContextSession() {
    auto& operationSession = operationSessionDecoration(_opCtx);
    operationSession.reset();
}