From 774faa6d4c318e47d672c411e6f84ef8768fee05 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 30 Nov 2023 19:27:04 +0000 Subject: [PATCH 1/2] session manager in memory, addressing TODO. does not seem to bring down performance. --- src/lib/tls/tls_session_manager_memory.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/lib/tls/tls_session_manager_memory.cpp b/src/lib/tls/tls_session_manager_memory.cpp index 7d1543a2181..a4c073c9f4e 100644 --- a/src/lib/tls/tls_session_manager_memory.cpp +++ b/src/lib/tls/tls_session_manager_memory.cpp @@ -67,12 +67,9 @@ std::vector Session_Manager_In_Memory::find_some(const Serv lock_guard_type lk(mutex()); std::vector found_sessions; - // TODO: std::copy_if? - for(const auto& [_, session_and_handle] : m_sessions) { - if(session_and_handle.session.server_info() == info) { - found_sessions.emplace_back(session_and_handle); - } - } + std::ranges::copy_if(m_sessions | std::views::values, std::back_inserter(found_sessions), [&](const auto& e) { + return e.session.server_info() == info; + }); return found_sessions; } From 862504cbbc5835162da9844cad43c88191f55ef6 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 7 Dec 2023 13:24:08 +0000 Subject: [PATCH 2/2] issue with clang < 16 it seems --- src/lib/tls/tls_session_manager_memory.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/tls/tls_session_manager_memory.cpp b/src/lib/tls/tls_session_manager_memory.cpp index a4c073c9f4e..2a3d3474100 100644 --- a/src/lib/tls/tls_session_manager_memory.cpp +++ b/src/lib/tls/tls_session_manager_memory.cpp @@ -67,9 +67,10 @@ std::vector Session_Manager_In_Memory::find_some(const Serv lock_guard_type lk(mutex()); std::vector found_sessions; - std::ranges::copy_if(m_sessions | std::views::values, std::back_inserter(found_sessions), [&](const auto& e) { - return e.session.server_info() == info; - }); + std::vector tmp; + std::ranges::transform(m_sessions, std::back_inserter(tmp), [](const auto& e) { return e.second; }); + std::ranges::copy_if( + tmp, std::back_inserter(found_sessions), [&](const auto& e) { return e.session.server_info() == info; }); return found_sessions; }