commit 58ce8ea: [Minor] Minor debugging improvements

Vsevolod Stakhov vsevolod at rspamd.com
Sat Sep 10 14:00:05 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-09-10 14:57:18 +0100
URL: https://github.com/rspamd/rspamd/commit/58ce8ea685a757d783ae8a65c2958a48e81f85eb (HEAD -> master)

[Minor] Minor debugging improvements

---
 src/libserver/symcache/symcache_impl.cxx | 28 ++++++++++++++++++----------
 src/plugins/lua/url_redirector.lua       |  1 +
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/src/libserver/symcache/symcache_impl.cxx b/src/libserver/symcache/symcache_impl.cxx
index 451222f2f..7b1127a7a 100644
--- a/src/libserver/symcache/symcache_impl.cxx
+++ b/src/libserver/symcache/symcache_impl.cxx
@@ -1221,13 +1221,14 @@ auto symcache::get_max_timeout(std::vector<std::pair<double, const cache_item *>
 		const cache_item *max_elt = nullptr;
 		for (const auto &it : vec) {
 			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);"
-									   "symbol: %s",
-						max_timeout, accumulated_timeout, saved_priority, it->priority,
-						it->symbol.c_str());
 				if (!seen_items.contains(max_elt)) {
+					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); "
+										   "symbol: %s",
+							max_timeout, accumulated_timeout, saved_priority, it->priority,
+							max_elt->symbol.c_str());
 					elts.emplace_back(max_timeout, max_elt);
 					seen_items.insert(max_elt);
 				}
@@ -1245,9 +1246,14 @@ auto symcache::get_max_timeout(std::vector<std::pair<double, const cache_item *>
 		}
 
 		if (max_elt != nullptr && max_timeout > 0) {
-			accumulated_timeout += max_timeout;
-			added_timeout += max_timeout;
 			if (!seen_items.contains(max_elt)) {
+				accumulated_timeout += max_timeout;
+				added_timeout += max_timeout;
+
+				msg_debug_cache_lambda("added %.2f to the timeout (%.2f) end of processing; "
+									   "symbol: %s",
+						max_timeout, accumulated_timeout,
+						max_elt->symbol.c_str());
 				elts.emplace_back(max_timeout, max_elt);
 				seen_items.insert(max_elt);
 			}
@@ -1257,8 +1263,6 @@ auto symcache::get_max_timeout(std::vector<std::pair<double, const cache_item *>
 	};
 
 	auto prefilters_timeout = pre_postfilter_iter(this->prefilters);
-	auto postfilters_timeout = pre_postfilter_iter(this->postfilters);
-	auto idempotent_timeout = pre_postfilter_iter(this->idempotent);
 
 	/* For normal filters, we check the maximum chain of the dependencies
 	 * This function might have O(N^2) complexity if all symbols are in a single
@@ -1278,6 +1282,10 @@ auto symcache::get_max_timeout(std::vector<std::pair<double, const cache_item *>
 	}
 
 	accumulated_timeout += max_filters_timeout;
+
+	auto postfilters_timeout = pre_postfilter_iter(this->postfilters);
+	auto idempotent_timeout = pre_postfilter_iter(this->idempotent);
+
 	/* Sort in decreasing order by timeout */
 	std::stable_sort(std::begin(elts), std::end(elts),
 					 [](const auto &p1, const auto &p2) {
diff --git a/src/plugins/lua/url_redirector.lua b/src/plugins/lua/url_redirector.lua
index bc054ec69..641d8de66 100644
--- a/src/plugins/lua/url_redirector.lua
+++ b/src/plugins/lua/url_redirector.lua
@@ -356,6 +356,7 @@ if opts then
       local id = rspamd_config:register_symbol{
         name = 'URL_REDIRECTOR_CHECK',
         type = 'callback,prefilter',
+        priority = lua_util.symbols_priorities.medium,
         callback = url_redirector_handler,
         -- In fact, the real timeout is nested_limit * timeout...
         augmentations = {string.format("timeout=%f", settings.timeout)}


More information about the Commits mailing list