From 02227976fd12c40beb2fcfd2361c52e02b9f06ab Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Wed, 4 Apr 2018 14:03:44 +0000 Subject: Abort if document type repo isn't empty at shutdown. --- .../document/repo/document_type_repo_factory.cpp | 30 +++++++++++++++++++++- .../document/repo/document_type_repo_factory.h | 1 + 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'document') 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 -#include +#include +#include + 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 make(const DocumenttypesConfig &config); + static bool empty(); }; } -- cgit v1.2.3