summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorMatthew Russotto <matthew.russotto@10gen.com>2019-07-31 15:45:59 -0400
committerMatthew Russotto <matthew.russotto@10gen.com>2019-08-23 16:47:57 -0400
commitadecec418601ccc2690c4e4750d06087ad43fb10 (patch)
tree76b728219cb03d435b937241d78d77e8c82eefb4 /src/mongo/db
parent7727804534b7c12dbe4c624b7ac24f566a353543 (diff)
downloadmongo-adecec418601ccc2690c4e4750d06087ad43fb10.tar.gz
SERVER-39776 Remove legacy UniqueLock and LockGuard from repl_coordinator_external_state_impl.cpp
(cherry picked from commit 025c02738625a57ff738942b660832b794510fb1)
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.cpp29
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.h5
2 files changed, 14 insertions, 20 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
index 700d7978cdf..b4896745912 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
@@ -111,9 +111,6 @@ namespace mongo {
namespace repl {
namespace {
-using UniqueLock = stdx::unique_lock<stdx::mutex>;
-using LockGuard = stdx::lock_guard<stdx::mutex>;
-
const char localDbName[] = "local";
const char configCollectionName[] = "local.system.replset";
const auto configDatabaseName = localDbName;
@@ -207,7 +204,7 @@ bool ReplicationCoordinatorExternalStateImpl::isInitialSyncFlagSet(OperationCont
void ReplicationCoordinatorExternalStateImpl::startSteadyStateReplication(
OperationContext* opCtx, ReplicationCoordinator* replCoord) {
- LockGuard lk(_threadMutex);
+ stdx::lock_guard<stdx::mutex> lk(_threadMutex);
// We've shut down the external state, don't start again.
if (_inShutdown)
@@ -258,21 +255,21 @@ void ReplicationCoordinatorExternalStateImpl::startSteadyStateReplication(
}
void ReplicationCoordinatorExternalStateImpl::stopDataReplication(OperationContext* opCtx) {
- UniqueLock lk(_threadMutex);
- _stopDataReplication_inlock(opCtx, &lk);
+ stdx::unique_lock<stdx::mutex> lk(_threadMutex);
+ _stopDataReplication_inlock(opCtx, lk);
}
-void ReplicationCoordinatorExternalStateImpl::_stopDataReplication_inlock(OperationContext* opCtx,
- UniqueLock* lock) {
+void ReplicationCoordinatorExternalStateImpl::_stopDataReplication_inlock(
+ OperationContext* opCtx, stdx::unique_lock<stdx::mutex>& lock) {
// Make sue no other _stopDataReplication calls are in progress.
- _dataReplicationStopped.wait(*lock, [this]() { return !_stoppingDataReplication; });
+ _dataReplicationStopped.wait(lock, [this]() { return !_stoppingDataReplication; });
_stoppingDataReplication = true;
auto oldSSF = std::move(_syncSourceFeedbackThread);
auto oldOplogBuffer = std::move(_oplogBuffer);
auto oldBgSync = std::move(_bgSync);
auto oldApplier = std::move(_oplogApplier);
- lock->unlock();
+ lock.unlock();
// _syncSourceFeedbackThread should be joined before _bgSync's shutdown because it has
// a pointer of _bgSync.
@@ -311,7 +308,7 @@ void ReplicationCoordinatorExternalStateImpl::_stopDataReplication_inlock(Operat
oldOplogBuffer->shutdown(opCtx);
}
- lock->lock();
+ lock.lock();
_stoppingDataReplication = false;
_dataReplicationStopped.notify_all();
}
@@ -338,13 +335,13 @@ void ReplicationCoordinatorExternalStateImpl::startThreads(const ReplSettings& s
}
void ReplicationCoordinatorExternalStateImpl::shutdown(OperationContext* opCtx) {
- UniqueLock lk(_threadMutex);
+ stdx::unique_lock<stdx::mutex> lk(_threadMutex);
if (!_startedThreads) {
return;
}
_inShutdown = true;
- _stopDataReplication_inlock(opCtx, &lk);
+ _stopDataReplication_inlock(opCtx, lk);
if (_noopWriter) {
LOG(1) << "Stopping noop writer";
@@ -819,21 +816,21 @@ void ReplicationCoordinatorExternalStateImpl::_shardingOnTransitionToPrimaryHook
}
void ReplicationCoordinatorExternalStateImpl::signalApplierToChooseNewSyncSource() {
- LockGuard lk(_threadMutex);
+ stdx::lock_guard<stdx::mutex> lk(_threadMutex);
if (_bgSync) {
_bgSync->clearSyncTarget();
}
}
void ReplicationCoordinatorExternalStateImpl::stopProducer() {
- LockGuard lk(_threadMutex);
+ stdx::lock_guard<stdx::mutex> lk(_threadMutex);
if (_bgSync) {
_bgSync->stop(false);
}
}
void ReplicationCoordinatorExternalStateImpl::startProducerIfStopped() {
- LockGuard lk(_threadMutex);
+ stdx::lock_guard<stdx::mutex> lk(_threadMutex);
if (_bgSync) {
_bgSync->startProducerIfStopped();
}
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.h b/src/mongo/db/repl/replication_coordinator_external_state_impl.h
index 41abb8bc4e6..caacf96c068 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.h
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.h
@@ -46,9 +46,6 @@ namespace mongo {
class ServiceContext;
namespace repl {
-namespace {
-using UniqueLock = stdx::unique_lock<stdx::mutex>;
-} // namespace
class DropPendingCollectionReaper;
class ReplicationProcess;
@@ -123,7 +120,7 @@ private:
/**
* Stops data replication and returns with 'lock' locked.
*/
- void _stopDataReplication_inlock(OperationContext* opCtx, UniqueLock* lock);
+ void _stopDataReplication_inlock(OperationContext* opCtx, stdx::unique_lock<stdx::mutex>& lock);
/**
* Called when the instance transitions to primary in order to notify a potentially sharded host