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);"
/* 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,"
static bool
rspamd_maybe_reuseport_socket (struct rspamd_worker_listen_socket *ls)
{
- gint nfd = -1;
-
if (ls->is_systemd) {
/* No need to reuseport */
return true;
}
#if defined(SO_REUSEPORT) && defined(SO_REUSEADDR) && defined(LINUX)
+ gint nfd = -1;
if (ls->type == RSPAMD_WORKER_SOCKET_UDP) {
nfd = rspamd_inet_address_listen (ls->addr,
*/
nfd = ls->fd;
}
-#else
- nfd = ls->fd;
#endif
#if 0
g_assert (tres != 0);
if (tres->max_timeout > timeout) {
- msg_info_config("configured task_timeout %.2f is less than maximum symbols cache timeout %.2f, so"
- "some symbols could be terminated early", timeout, tres->max_timeout);
- /* TODO: list timeouts for top symbols */
+ msg_info_config("configured task_timeout %.2f is less than maximum symbols cache timeout %.2f; "
+ "some symbols can be terminated before checks", timeout, tres->max_timeout);
+ GString *buf = g_string_sized_new(512);
+ static const int max_displayed_items = 12;
+
+ for (int i = 0; i < MIN(tres->nitems, max_displayed_items); i++) {
+ if (i == 0) {
+ rspamd_printf_gstring(buf, "%s(%.2f)",
+ rspamd_symcache_item_name((struct rspamd_symcache_item *)tres->items[i].item),
+ tres->items[i].timeout);
+ }
+ else {
+ rspamd_printf_gstring(buf, "; %s(%.2f)",
+ rspamd_symcache_item_name((struct rspamd_symcache_item *)tres->items[i].item),
+ tres->items[i].timeout);
+ }
+ }
+ msg_info_config("list of top %d symbols by execution time: %v",
+ MIN(tres->nitems, max_displayed_items),
+ buf);
+
+ g_string_free(buf, TRUE);
}
rspamd_symcache_timeout_result_free (tres);