diff options
author | Tor Egge <Tor.Egge@oath.com> | 2018-04-04 14:03:44 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@oath.com> | 2018-04-04 14:11:05 +0000 |
commit | 02227976fd12c40beb2fcfd2361c52e02b9f06ab (patch) | |
tree | 5d2e8bd297033dee6877700f5496044671c985ce | |
parent | a3d2dad8b01377a87754b714f54ff05c87bf1f8c (diff) |
Abort if document type repo isn't empty at shutdown.
-rw-r--r-- | document/src/vespa/document/repo/document_type_repo_factory.cpp | 30 | ||||
-rw-r--r-- | document/src/vespa/document/repo/document_type_repo_factory.h | 1 |
2 files changed, 30 insertions, 1 deletions
diff --git a/document/src/vespa/document/repo/document_type_repo_factory.cpp b/document/src/vespa/document/repo/document_type_repo_factory.cpp index 8224d0f2c9a..ce8d19ae5a2 100644 --- a/document/src/vespa/document/repo/document_type_repo_factory.cpp +++ b/document/src/vespa/document/repo/document_type_repo_factory.cpp @@ -3,13 +3,35 @@ #include "document_type_repo_factory.h" #include "documenttyperepo.h" #include <vespa/document/config/config-documenttypes.h> -#include <functional> +#include <iostream> +#include <stdexcept> + namespace document { std::mutex DocumentTypeRepoFactory::_mutex; DocumentTypeRepoFactory::DocumentTypeRepoMap DocumentTypeRepoFactory::_repos; +namespace { + +class EmptyFactoryCheck +{ +public: + ~EmptyFactoryCheck(); +}; + +EmptyFactoryCheck::~EmptyFactoryCheck() +{ + if (!DocumentTypeRepoFactory::empty()) { + std::cerr << "DocumentTypeRepoFactory not empty at shutdown" << std::endl; + abort(); + } +} + +EmptyFactoryCheck emptyFactoryCheck; + +} + /* * Class handling deletion of document type repo after last reference is gone. */ @@ -48,4 +70,10 @@ DocumentTypeRepoFactory::make(const DocumenttypesConfig &config) return repo; } +bool +DocumentTypeRepoFactory::empty() +{ + return _repos.empty(); +} + } diff --git a/document/src/vespa/document/repo/document_type_repo_factory.h b/document/src/vespa/document/repo/document_type_repo_factory.h index e104fe1f6a0..4bf65d61645 100644 --- a/document/src/vespa/document/repo/document_type_repo_factory.h +++ b/document/src/vespa/document/repo/document_type_repo_factory.h @@ -44,6 +44,7 @@ public: * pointer to a const repo. The repo should be considered immutable. */ static std::shared_ptr<const DocumentTypeRepo> make(const DocumenttypesConfig &config); + static bool empty(); }; } |