diff options
Diffstat (limited to 'src/mongo/db/storage/encryption_hooks.cpp')
-rw-r--r-- | src/mongo/db/storage/encryption_hooks.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/mongo/db/storage/encryption_hooks.cpp b/src/mongo/db/storage/encryption_hooks.cpp index 8a81d20dd2d..bb5c60a29b8 100644 --- a/src/mongo/db/storage/encryption_hooks.cpp +++ b/src/mongo/db/storage/encryption_hooks.cpp @@ -41,13 +41,16 @@ namespace mongo { /* Make a EncryptionHooks pointer a decoration on the global ServiceContext */ -MONGO_INITIALIZER(SetEncryptionHooks) -(InitializerContext* context) { - auto encryptionHooks = stdx::make_unique<EncryptionHooks>(); - EncryptionHooks::set(getGlobalServiceContext(), std::move(encryptionHooks)); - - return Status::OK(); -} +GlobalInitializerRegisterer encryptionHooksInitializer( + "SetEncryptionHooks", + [](InitializerContext* context) { + EncryptionHooks::set(context->serviceContext(), stdx::make_unique<EncryptionHooks>()); + return Status::OK(); + }, + [](DeinitializerContext* context) { + EncryptionHooks::set(context->serviceContext(), nullptr); + return Status::OK(); + }); namespace { const auto getEncryptionHooks = @@ -55,9 +58,7 @@ const auto getEncryptionHooks = } // namespace void EncryptionHooks::set(ServiceContext* service, std::unique_ptr<EncryptionHooks> custHooks) { - auto& hooks = getEncryptionHooks(service); - invariant(custHooks); - hooks = std::move(custHooks); + getEncryptionHooks(service) = std::move(custHooks); } EncryptionHooks* EncryptionHooks::get(ServiceContext* service) { |