]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Allow to set 0 as number of rows to disable roll history
authorVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 29 Apr 2024 15:21:56 +0000 (16:21 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 29 Apr 2024 15:23:51 +0000 (16:23 +0100)
Issue: #4947
Closes: #4947
src/controller.c
src/libserver/protocol.c
src/rspamd.c

index b287f89d839c4fd02024accf879e5cc9e19caf26..063c1c1631f34147c4582c2037bcb398635b5bea 100644 (file)
@@ -1682,7 +1682,7 @@ rspamd_controller_handle_history(struct rspamd_http_connection_entry *conn_ent,
 
        L = ctx->cfg->lua_state;
 
-       if (!ctx->srv->history->disabled) {
+       if (ctx->srv->history && !ctx->srv->history->disabled) {
                rspamd_controller_handle_legacy_history(session, ctx, conn_ent, msg);
        }
        else {
@@ -1765,7 +1765,7 @@ rspamd_controller_handle_history_reset(struct rspamd_http_connection_entry *conn
                return 0;
        }
 
-       if (!ctx->srv->history->disabled) {
+       if (ctx->srv->history && !ctx->srv->history->disabled) {
                /* Clean from start to the current row */
                completed_rows = g_atomic_int_get(&ctx->srv->history->cur_row);
 
index 5de980352b4301ee0cfca771953d06c0ae45c10b..c8c7bc76ae3595fd5f577150e0572c757b8ad178 100644 (file)
@@ -1666,7 +1666,9 @@ void rspamd_protocol_http_reply(struct rspamd_http_message *msg,
        }
 
        if (!(task->flags & RSPAMD_TASK_FLAG_NO_LOG)) {
-               rspamd_roll_history_update(task->worker->srv->history, task);
+               if (task->worker->srv->history) {
+                       rspamd_roll_history_update(task->worker->srv->history, task);
+               }
        }
        else {
                msg_debug_protocol("skip history update due to no log flag");
index 8d4c83a28491eafb76249751ed575276043a7e7a..dc5535f0cebc157c579e55c381663741f3237e07 100644 (file)
@@ -1532,7 +1532,8 @@ int main(int argc, char **argv, char **env)
 
        /* Create rolling history */
        rspamd_main->history = rspamd_roll_history_new(rspamd_main->server_pool,
-                                                                                                  rspamd_main->cfg->history_rows, rspamd_main->cfg);
+                                                                                                  rspamd_main->cfg->history_rows,
+                                                                                                  rspamd_main->cfg);
 
        msg_info_main("rspamd " RVERSION
                                  " is starting, build id: " RID);
@@ -1609,7 +1610,7 @@ int main(int argc, char **argv, char **env)
        }
 
        /* Maybe read roll history */
-       if (rspamd_main->cfg->history_file) {
+       if (rspamd_main->history && rspamd_main->cfg->history_file) {
                rspamd_roll_history_load(rspamd_main->history,
                                                                 rspamd_main->cfg->history_file);
        }
@@ -1692,7 +1693,7 @@ int main(int argc, char **argv, char **env)
        ev_loop(event_loop, 0);
 
        /* Maybe save roll history */
-       if (rspamd_main->cfg->history_file) {
+       if (rspamd_main->history && rspamd_main->cfg->history_file) {
                rspamd_roll_history_save(rspamd_main->history,
                                                                 rspamd_main->cfg->history_file);
        }