diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-02-21 21:47:56 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-02-22 07:23:53 +0000 |
commit | 09d47cf99bf75fcf1ac956649c260767fd08ccce (patch) | |
tree | dcdaebd2233bf7c494e12b5ecf5c90e8b47f7e1c /searchcore | |
parent | 8a382bd5819f2e2f7653f604cc018b394770fe44 (diff) |
Ensure we close down in correct order.
Diffstat (limited to 'searchcore')
3 files changed, 16 insertions, 0 deletions
diff --git a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp index bef8d0c49bb..c6a8df79a5e 100644 --- a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp @@ -35,6 +35,7 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/config/subscription/sourcespec.h> +#include <vespa/fnet/transport.h> #include <iostream> using namespace cloud::config::filedistribution; @@ -177,6 +178,8 @@ Fixture::Fixture(bool file_config) Fixture::~Fixture() { + _db->close(); + _shared_service.transport().ShutDown(true); } std::unique_ptr<ConfigStore> diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.cpp b/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.cpp index f956a370ffa..4e12ea97a0d 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.cpp @@ -26,7 +26,9 @@ ProtonConfigFetcher::ProtonConfigFetcher(FNET_Transport & transport, const confi _retriever(_bootstrapConfigManager.createConfigKeySet(), configUri.getContext(), subscribeTimeout), _owner(owner), _mutex(), + _cond(), _dbManagerMap(), + _running(false), _oldDocumentTypeRepos(), _currentDocumentTypeRepo() { @@ -50,6 +52,9 @@ ProtonConfigFetcher::Run(FastOS_ThreadInterface * thread, void *arg) std::this_thread::sleep_for(100ms); } } + lock_guard guard(_mutex); + _running = false; + _cond.notify_all(); } const ConfigKeySet @@ -168,6 +173,8 @@ ProtonConfigFetcher::start(FastOS_ThreadPool & threadPool) throw vespalib::IllegalStateException( "Failed starting thread for proton config fetcher"); } + lock_guard guard(_mutex); + _running = true; } void @@ -176,6 +183,10 @@ ProtonConfigFetcher::close() if (!_retriever.isClosed()) { _retriever.close(); } + std::unique_lock<std::mutex> guard(_mutex); + while (_running) { + _cond.wait(guard); + } } void diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h b/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h index 11123c49fcb..77184f01604 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h @@ -57,7 +57,9 @@ private: IProtonConfigurer & _owner; mutable std::mutex _mutex; // Protects maps + std::condition_variable _cond; DBManagerMap _dbManagerMap; + bool _running; std::deque<OldDocumentTypeRepo> _oldDocumentTypeRepos; std::shared_ptr<const document::DocumentTypeRepo> _currentDocumentTypeRepo; |