]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Stop periodics on terminate
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Nov 2019 11:29:49 +0000 (11:29 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Nov 2019 11:29:49 +0000 (11:29 +0000)
src/libserver/cfg_file.h
src/libserver/worker_util.c
src/libutil/map.c
src/lua/lua_config.c

index 1cf4a1fafb1ceaf29321fbeb97b55cbb88df1858..96a44f45e22c898456ffc31409b881fe49e56bc8 100644 (file)
@@ -493,6 +493,7 @@ struct rspamd_config {
 
        struct rspamd_config_settings_elt *setting_ids;    /**< preprocessed settings ids                                                       */
        struct rspamd_lang_detector *lang_det;            /**< language detector                                                                        */
+       struct rspamd_worker *cur_worker;               /**< set dynamically by each worker                                                     */
 
        ref_entry_t ref;                                /**< reference counter                                                                  */
 };
index e3927063d545060e833e4dd6b3a9d610a100ed85..aff418abe24d6a34db23e1e357044b7533553ee4 100644 (file)
@@ -1054,6 +1054,7 @@ rspamd_fork_worker (struct rspamd_main *rspamd_main,
                close (wrk->srv_pipe[0]);
                rspamd_socket_nonblocking (wrk->control_pipe[1]);
                rspamd_socket_nonblocking (wrk->srv_pipe[1]);
+               rspamd_main->cfg->cur_worker = wrk;
                /* Execute worker */
                cf->worker->worker_start_func (wrk);
                exit (EXIT_FAILURE);
index 8da3c7bd4cb80e404b8131c21a85d4aea6435403..dcdb58f351d45ffc5c836f61f34f6f0ac44bd3fb 100644 (file)
@@ -974,6 +974,10 @@ rspamd_map_periodic_dtor (struct map_periodic_cbdata *periodic)
                        rspamd_map_schedule_periodic (periodic->map,
                                        RSPAMD_SYMBOL_RESULT_NORMAL);
                }
+               else {
+                       msg_debug_map ("stop scheduling periodics for %s; terminating state",
+                                       periodic->map->name);
+               }
        }
 
        g_free (periodic);
index 33873d8abb3b077d211dbbb357a6931be46e5e03..b7bddc34bc43d4b614be69a2099f43cd42b8e011 100644 (file)
@@ -3186,6 +3186,14 @@ lua_periodic_callback_finish (struct thread_entry *thread, int ret)
 
                lua_pop (L, 1); /* Return value */
        }
+
+       if (periodic->cfg->cur_worker) {
+               if (periodic->cfg->cur_worker->state != rspamd_worker_state_running) {
+                       /* We are terminating, no more periodics */
+                       plan_more = FALSE;
+               }
+       }
+
        if (plan_more) {
                if (periodic->need_jitter) {
                        timeout = rspamd_time_jitter (timeout, 0.0);