diff options
author | Nathan Myers <ncm@cantrip.org> | 2017-08-18 13:42:27 -0400 |
---|---|---|
committer | Nathan Myers <ncm@cantrip.org> | 2017-08-23 23:35:06 -0400 |
commit | 200d56c6eec8acdc6cddf0541f31c60f4ed2e760 (patch) | |
tree | c90fcee8cd991ff171f3e1f9c83b5325e131d2d4 /src/mongo/db/s/balancer/migration_manager.cpp | |
parent | 655d02968973aec47b63aa750dadd10386adb3c8 (diff) | |
download | mongo-200d56c6eec8acdc6cddf0541f31c60f4ed2e760.tar.gz |
SERVER-30748 WithLock to replace _inlock
Diffstat (limited to 'src/mongo/db/s/balancer/migration_manager.cpp')
-rw-r--r-- | src/mongo/db/s/balancer/migration_manager.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/mongo/db/s/balancer/migration_manager.cpp b/src/mongo/db/s/balancer/migration_manager.cpp index 9552c959323..cd2d1baa30e 100644 --- a/src/mongo/db/s/balancer/migration_manager.cpp +++ b/src/mongo/db/s/balancer/migration_manager.cpp @@ -399,7 +399,7 @@ void MigrationManager::interruptAndDisableMigrations() { } } - _checkDrained_inlock(); + _checkDrained(lock); } void MigrationManager::drainActiveMigrations() { @@ -470,14 +470,15 @@ shared_ptr<Notification<RemoteCommandResponse>> MigrationManager::_schedule( auto retVal = migration.completionNotification; - _schedule_inlock(opCtx, fromHostStatus.getValue(), std::move(migration)); + _schedule(lock, opCtx, fromHostStatus.getValue(), std::move(migration)); return retVal; } -void MigrationManager::_schedule_inlock(OperationContext* opCtx, - const HostAndPort& targetHost, - Migration migration) { +void MigrationManager::_schedule(WithLock lock, + OperationContext* opCtx, + const HostAndPort& targetHost, + Migration migration) { executor::TaskExecutor* const executor = Grid::get(opCtx)->getExecutorPool()->getFixedExecutor(); @@ -526,7 +527,7 @@ void MigrationManager::_schedule_inlock(OperationContext* opCtx, auto opCtx = cc().makeOperationContext(); stdx::lock_guard<stdx::mutex> lock(_mutex); - _complete_inlock(opCtx.get(), itMigration, args.response); + _complete(lock, opCtx.get(), itMigration, args.response); }); if (callbackHandleWithStatus.isOK()) { @@ -534,12 +535,13 @@ void MigrationManager::_schedule_inlock(OperationContext* opCtx, return; } - _complete_inlock(opCtx, itMigration, std::move(callbackHandleWithStatus.getStatus())); + _complete(lock, opCtx, itMigration, std::move(callbackHandleWithStatus.getStatus())); } -void MigrationManager::_complete_inlock(OperationContext* opCtx, - MigrationsList::iterator itMigration, - const RemoteCommandResponse& remoteCommandResponse) { +void MigrationManager::_complete(WithLock lock, + OperationContext* opCtx, + MigrationsList::iterator itMigration, + const RemoteCommandResponse& remoteCommandResponse) { const NamespaceString nss(itMigration->nss); // Make sure to signal the notification last, after the distributed lock is freed, so that we @@ -557,13 +559,13 @@ void MigrationManager::_complete_inlock(OperationContext* opCtx, Grid::get(opCtx)->catalogClient()->getDistLockManager()->unlock( opCtx, _lockSessionID, nss.ns()); _activeMigrations.erase(it); - _checkDrained_inlock(); + _checkDrained(lock); } notificationToSignal->set(remoteCommandResponse); } -void MigrationManager::_checkDrained_inlock() { +void MigrationManager::_checkDrained(WithLock) { if (_state == State::kEnabled || _state == State::kRecovering) { return; } |