diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-09-10 14:13:30 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-09-10 14:13:30 +0100 |
commit | e49a9382bee59c794293e036171be67f7016962e (patch) | |
tree | cf8c363d614dcb76b2e245b640d78ff197281de3 /src/libserver/symcache | |
parent | 53f33e0992fbbdaa71132421aeb92218dfbc867a (diff) | |
download | rspamd-e49a9382bee59c794293e036171be67f7016962e.tar.gz rspamd-e49a9382bee59c794293e036171be67f7016962e.zip |
[Minor] Properly print top symbols by timeout
Diffstat (limited to 'src/libserver/symcache')
-rw-r--r-- | src/libserver/symcache/symcache_c.cxx | 2 | ||||
-rw-r--r-- | src/libserver/symcache/symcache_impl.cxx | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/libserver/symcache/symcache_c.cxx b/src/libserver/symcache/symcache_c.cxx index f957aa9b6..f8de95281 100644 --- a/src/libserver/symcache/symcache_c.cxx +++ b/src/libserver/symcache/symcache_c.cxx @@ -265,7 +265,7 @@ rspamd_symcache_item_name(struct rspamd_symcache_item *item) auto *real_item = C_API_SYMCACHE_ITEM(item); if (real_item == nullptr) { - return 0; + return nullptr; } return real_item->get_name().c_str(); diff --git a/src/libserver/symcache/symcache_impl.cxx b/src/libserver/symcache/symcache_impl.cxx index b2f6004aa..e7e0a56b0 100644 --- a/src/libserver/symcache/symcache_impl.cxx +++ b/src/libserver/symcache/symcache_impl.cxx @@ -1215,7 +1215,7 @@ auto symcache::get_max_timeout(std::vector<std::pair<double, const cache_item *> auto max_timeout = 0.0, added_timeout = 0.0; const cache_item *max_elt = nullptr; for (const auto &it : vec) { - if (it->priority != saved_priority) { + if (it->priority != saved_priority && max_elt != nullptr && max_timeout > 0) { accumulated_timeout += max_timeout; added_timeout += max_timeout; msg_debug_cache_lambda("added %.2f to the timeout (%.2f) as the priority has changed (%d -> %d);" @@ -1276,7 +1276,7 @@ auto symcache::get_max_timeout(std::vector<std::pair<double, const cache_item *> /* Sort in decreasing order by timeout */ std::stable_sort(std::begin(elts), std::end(elts), [](const auto &p1, const auto &p2) { - return p2.first > p1.first; + return p1.first > p2.first; }); msg_debug_cache("overall cache timeout: %.2f, %.2f from prefilters," |