diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-06-20 15:54:57 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-06-20 15:54:57 +0100 |
commit | 1609c243964270bf033f6b79bd7946be3fec33f9 (patch) | |
tree | 03e72859cd893cb93e477153fc8a71aa8cedd452 | |
parent | 84a77c2132d0de1218e3476bfbac164561bb9726 (diff) | |
download | rspamd-1609c243964270bf033f6b79bd7946be3fec33f9.tar.gz rspamd-1609c243964270bf033f6b79bd7946be3fec33f9.zip |
[Project] Finally fix slow timer behaviour
-rw-r--r-- | src/libserver/symcache/symcache_runtime.cxx | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/libserver/symcache/symcache_runtime.cxx b/src/libserver/symcache/symcache_runtime.cxx index 8b341d6e0..c02069fb2 100644 --- a/src/libserver/symcache/symcache_runtime.cxx +++ b/src/libserver/symcache/symcache_runtime.cxx @@ -789,11 +789,33 @@ auto symcache_runtime::finalize_item(struct rspamd_task *task, cache_dynamic_ite item->internal_flags |= cache_item::bit_slow; - if (!(item->internal_flags & cache_item::bit_sync)) { + if (item->internal_flags & cache_item::bit_sync) { + + /* + * We also need to adjust start timer for all async rules that + * are started before this rule, as this rule could delay them + * on its own. Hence, we need to make some corrections for all + * rules pending + */ + + for (const auto &[i, other_item]: rspamd::enumerate(order->d)) { + auto *other_dyn_item = &dynamic_items[i]; + + if (other_dyn_item->status == cache_item_status::pending && other_dyn_item->start_msec <= dyn_item->start_msec) { + other_dyn_item->start_msec += diff; + + msg_debug_cache_task("adjust start time for %s(%d) by %.2fms to %dms", + other_item->symbol.c_str(), + other_item->id, + diff, + (int) other_dyn_item->start_msec); + } + } + if (slow_status == slow_status::none) { slow_status = slow_status::enabled; - msg_info_task("slow rule: %s(%d): %.2f ms; enable 100ms idle timer to allow other rules to be finished", + msg_info_task("slow synchronous rule: %s(%d): %.2f ms; enable 100ms idle timer to allow other rules to be finished", item->symbol.c_str(), item->id, diff); if (enable_slow_timer()) { @@ -801,13 +823,13 @@ auto symcache_runtime::finalize_item(struct rspamd_task *task, cache_dynamic_ite } } else { - msg_info_task("slow rule: %s(%d): %.2f ms; idle timer has already been activated for this scan", + msg_info_task("slow synchronous rule: %s(%d): %.2f ms; idle timer has already been activated for this scan", item->symbol.c_str(), item->id, diff); } } else { - msg_notice_task("slow synchronous rule: %s(%d): %.2f ms; no idle timer is needed", + msg_notice_task("slow asynchronous rule: %s(%d): %.2f ms; no idle timer is needed", item->symbol.c_str(), item->id, diff); } |