summaryrefslogtreecommitdiff
path: root/src/mongo/db/operation_context_impl.cpp
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2015-05-29 18:13:48 -0400
committerSpencer T Brody <spencer@mongodb.com>2015-05-29 18:13:48 -0400
commite181ea38af737ef7aaf5f8228f870d8c7149b2bb (patch)
tree5c340753a9315e29b0c4b738c262eee7f538df64 /src/mongo/db/operation_context_impl.cpp
parentc6a542c1e69e0027c7a10f865cfa7767d5ed089d (diff)
downloadmongo-e181ea38af737ef7aaf5f8228f870d8c7149b2bb.tar.gz
Revert "SERVER-14995 Move operation id, lockState and client fields to OperationContext."
This reverts commit 4ea38c308da292f43e29d32b1b53b7324db0bafe.
Diffstat (limited to 'src/mongo/db/operation_context_impl.cpp')
-rw-r--r--src/mongo/db/operation_context_impl.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/mongo/db/operation_context_impl.cpp b/src/mongo/db/operation_context_impl.cpp
index 6eccefce706..b57090e04b9 100644
--- a/src/mongo/db/operation_context_impl.cpp
+++ b/src/mongo/db/operation_context_impl.cpp
@@ -69,30 +69,28 @@ namespace {
const auto clientOperationInfoDecoration = Client::declareDecoration<ClientOperationInfo>();
- AtomicUInt32 nextOpId{1};
} // namespace
using std::string;
OperationContextImpl::OperationContextImpl()
- : OperationContext(&cc(),
- nextOpId.fetchAndAdd(1),
- clientOperationInfoDecoration(cc()).getLocker()),
+ : _client(&cc()),
+ _locker(clientOperationInfoDecoration(_client).getLocker()),
_writesAreReplicated(true) {
+ invariant(_locker);
+
StorageEngine* storageEngine = getGlobalServiceContext()->getGlobalStorageEngine();
_recovery.reset(storageEngine->newRecoveryUnit());
- auto client = getClient();
- stdx::lock_guard<Client> lk(*client);
- client->setOperationContext(this);
+ stdx::lock_guard<Client> lk(*_client);
+ _client->setOperationContext(this);
}
OperationContextImpl::~OperationContextImpl() {
- lockState()->assertEmptyAndReset();
- auto client = getClient();
- stdx::lock_guard<Client> lk(*client);
- client->resetOperationContext();
+ _locker->assertEmptyAndReset();
+ stdx::lock_guard<Client> lk(*_client);
+ _client->resetOperationContext();
}
RecoveryUnit* OperationContextImpl::recoveryUnit() const {
@@ -115,6 +113,10 @@ namespace {
return oldState;
}
+ Locker* OperationContextImpl::lockState() const {
+ return _locker;
+ }
+
ProgressMeter* OperationContextImpl::setMessage(const char * msg,
const std::string &name,
unsigned long long progressMeterTotal,
@@ -126,6 +128,14 @@ namespace {
return CurOp::get(this)->getNS();
}
+ Client* OperationContextImpl::getClient() const {
+ return _client;
+ }
+
+ unsigned int OperationContextImpl::getOpID() const {
+ return CurOp::get(this)->opNum();
+ }
+
uint64_t OperationContextImpl::getRemainingMaxTimeMicros() const {
return CurOp::get(this)->getRemainingMaxTimeMicros();
}
@@ -198,7 +208,7 @@ namespace {
if (opShouldFail(this, scopedFailPoint.getData())) {
log() << "set pending kill on "
<< (curOp->parent() ? "nested" : "top-level")
- << " op " << getOpID() << ", for checkForInterruptFail";
+ << " op " << curOp->opNum() << ", for checkForInterruptFail";
curOp->kill();
}
}