From 4f022b784f01ed9120a44c014367cb2df8fd5df2 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 11 Oct 2021 09:58:16 +0100 Subject: [PATCH] [Fix] Fix compilation of the hyperscan databases with errors --- src/libserver/re_cache.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c index 82bbcee1c..91ef2cfa4 100644 --- a/src/libserver/re_cache.c +++ b/src/libserver/re_cache.c @@ -1862,12 +1862,19 @@ struct rspamd_re_cache_hs_compile_cbdata { static void rspamd_re_cache_compile_err (EV_P_ ev_timer *w, GError *err, - struct rspamd_re_cache_hs_compile_cbdata *cbdata) + struct rspamd_re_cache_hs_compile_cbdata *cbdata, bool is_fatal) { - ev_timer_stop (EV_A_ w); cbdata->cb (cbdata->total, err, cbdata->cbd); - g_free (w); - g_free (cbdata); + + if (is_fatal) { + ev_timer_stop(EV_A_ w); + g_free(w); + g_free(cbdata); + } + else { + /* Continue compilation */ + ev_timer_again(EV_A_ w); + } g_error_free (err); } @@ -1954,7 +1961,7 @@ rspamd_re_cache_compile_timer_cb (EV_P_ ev_timer *w, int revents ) if (fd == -1) { err = g_error_new (rspamd_re_cache_quark (), errno, "cannot open file %s: %s", path, strerror (errno)); - rspamd_re_cache_compile_err (EV_A_ w, err, cbdata); + rspamd_re_cache_compile_err (EV_A_ w, err, cbdata, false); return; } @@ -2074,7 +2081,7 @@ rspamd_re_cache_compile_timer_cb (EV_P_ ev_timer *w, int revents ) unlink (path); hs_free_compile_error (hs_errors); - rspamd_re_cache_compile_err (EV_A_ w, err, cbdata); + rspamd_re_cache_compile_err (EV_A_ w, err, cbdata, false); return; } @@ -2099,7 +2106,7 @@ rspamd_re_cache_compile_timer_cb (EV_P_ ev_timer *w, int revents ) g_free (hs_flags); hs_free_database (test_db); - rspamd_re_cache_compile_err (EV_A_ w, err, cbdata); + rspamd_re_cache_compile_err (EV_A_ w, err, cbdata, false); return; } @@ -2156,7 +2163,7 @@ rspamd_re_cache_compile_timer_cb (EV_P_ ev_timer *w, int revents ) g_free (hs_flags); g_free (hs_serialized); - rspamd_re_cache_compile_err (EV_A_ w, err, cbdata); + rspamd_re_cache_compile_err (EV_A_ w, err, cbdata, false); return; } @@ -2197,7 +2204,7 @@ rspamd_re_cache_compile_timer_cb (EV_P_ ev_timer *w, int revents ) unlink (path); close (fd); - rspamd_re_cache_compile_err (EV_A_ w, err, cbdata); + rspamd_re_cache_compile_err (EV_A_ w, err, cbdata, false); return; } @@ -2217,7 +2224,7 @@ rspamd_re_cache_compile_timer_cb (EV_P_ ev_timer *w, int revents ) g_free (hs_flags); unlink (path); close (fd); - rspamd_re_cache_compile_err (EV_A_ w, err, cbdata); + rspamd_re_cache_compile_err (EV_A_ w, err, cbdata, false); return; } -- 2.39.5