diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-01-17 10:12:38 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-01-17 10:12:38 +0000 |
commit | 162240c752f7872841e2bf6c4273d7a753319be8 (patch) | |
tree | 45f59795e53dc25e2a27f290a700fe3c67457fac /searchcore | |
parent | 319cbde398f507748601346b0ee49148330fc19c (diff) |
- Remove the explicit close method in SessionManager. Just do it in destructor instead.
- Destruct instead of close. Works even if it has not been constructed.
- Minor code cleanup.
Diffstat (limited to 'searchcore')
4 files changed, 16 insertions, 22 deletions
diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index ca689d4c4c6..fd6f6af730c 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_test.cpp @@ -126,16 +126,16 @@ struct EmptyRankingAssetsRepo : public proton::matching::IRankingAssetsRepo { //----------------------------------------------------------------------------- struct MyWorld { - Schema schema; - Properties config; - FakeSearchContext searchContext; - MockAttributeContext attributeContext; - SessionManager::SP sessionManager; - DocumentMetaStore metaStore; - MatchingStats matchingStats; - vespalib::TestClock clock; - QueryLimiter queryLimiter; - EmptyRankingAssetsRepo constantValueRepo; + Schema schema; + Properties config; + FakeSearchContext searchContext; + MockAttributeContext attributeContext; + std::shared_ptr<SessionManager> sessionManager; + DocumentMetaStore metaStore; + MatchingStats matchingStats; + vespalib::TestClock clock; + QueryLimiter queryLimiter; + EmptyRankingAssetsRepo constantValueRepo; MyWorld(); ~MyWorld(); diff --git a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp index d4ad82adbb1..1e74d83185f 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp @@ -173,7 +173,11 @@ SessionManager::SessionManager(uint32_t maxSize) _search_map(std::make_unique<SearchSessionCache>()) { } -SessionManager::~SessionManager() = default; +SessionManager::~SessionManager() { + pruneTimedOutSessions(vespalib::steady_time::max()); + assert(_grouping_cache->empty()); + assert(_search_map->empty()); +} void SessionManager::insert(search::grouping::GroupingSession::UP session) { _grouping_cache->insert(std::move(session)); @@ -215,12 +219,6 @@ void SessionManager::pruneTimedOutSessions(vespalib::steady_time currentTime) { _search_map->pruneTimedOutSessions(currentTime); } -void SessionManager::close() { - pruneTimedOutSessions(vespalib::steady_time::max()); - assert(_grouping_cache->empty()); - assert(_search_map->empty()); -} - SessionManager::Stats SessionManager::getGroupingStats() { return _grouping_cache->getStats(); } diff --git a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h index b193e61ff7d..3ed4760b52e 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h +++ b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h @@ -45,9 +45,6 @@ private: std::unique_ptr<SearchSessionCache> _search_map; public: - using UP = std::unique_ptr<SessionManager>; - using SP = std::shared_ptr<SessionManager>; - SessionManager(uint32_t maxSizeGrouping); ~SessionManager(); @@ -62,7 +59,6 @@ public: std::vector<SearchSessionInfo> getSortedSearchSessionInfo() const; void pruneTimedOutSessions(vespalib::steady_time currentTime); - void close(); }; } diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index 184637c02cf..6759335914d 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -499,7 +499,7 @@ Proton::~Proton() CpuUsage::wrap(proton_close_executor, CpuCategory::SETUP)); closeDocumentDBs(closePool); } - _sessionManager->close(); + _sessionManager.reset(); _documentDBMap.clear(); _persistenceEngine.reset(); _tls.reset(); |