]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add startup mutex
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 4 Apr 2016 17:20:48 +0000 (18:20 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 4 Apr 2016 17:20:48 +0000 (18:20 +0100)
src/log_helper.c
src/rspamd.c
src/rspamd.h

index 63e824420c55afbee4e4d023393ceab11cd18060..b1a241288a964e89d6e3ad65a89d472438b5eb10 100644 (file)
@@ -144,8 +144,11 @@ start_log_helper (struct rspamd_worker *worker)
        srv_cmd.type = RSPAMD_SRV_LOG_PIPE;
        srv_cmd.cmd.log_pipe.type = RSPAMD_LOG_PIPE_SYMBOLS;
 
+       /* Wait for startup being completed */
+       rspamd_mempool_lock_mutex (worker->srv->start_mtx);
        rspamd_srv_send_command (worker, ctx->ev_base, &srv_cmd, ctx->pair[1],
                        rspamd_log_helper_reply_handler, ctx);
+       rspamd_mempool_unlock_mutex (worker->srv->start_mtx);
        event_base_loop (ctx->ev_base, 0);
        close (ctx->pair[0]);
        rspamd_worker_block_signals ();
index 73be189c797c67a7b93d74c92ecea806905c7494..f6785fa99943376d850d3d42632fe878abc11567 100644 (file)
@@ -994,6 +994,7 @@ main (gint argc, gchar **argv, gchar **env)
        rspamd_main->cfg = rspamd_config_new ();
        rspamd_main->spairs = g_hash_table_new_full (rspamd_spair_hash,
                        rspamd_spair_equal, g_free, rspamd_spair_close);
+       rspamd_main->start_mtx = rspamd_mempool_get_mutex (rspamd_main->server_pool);
 
 #ifndef HAVE_SETPROCTITLE
        init_title (argc, argv, env);
@@ -1232,7 +1233,9 @@ main (gint argc, gchar **argv, gchar **env)
        event_add (&usr1_ev, NULL);
 
        rspamd_check_core_limits (rspamd_main);
+       rspamd_mempool_lock_mutex (rspamd_main->start_mtx);
        spawn_workers (rspamd_main, ev_base);
+       rspamd_mempool_unlock_mutex (rspamd_main->start_mtx);
 
        if (control_fd != -1) {
                msg_info_main ("listening for control commands on %s",
@@ -1291,6 +1294,7 @@ main (gint argc, gchar **argv, gchar **env)
        rspamd_log_close (rspamd_main->logger);
        REF_RELEASE (rspamd_main->cfg);
        g_hash_table_unref (rspamd_main->spairs);
+       rspamd_mempool_delete (rspamd_main->server_pool);
        g_free (rspamd_main);
        event_base_free (ev_base);
 
index 286a929f8609fa412f543f6cb22641baeab1599c..a677f02c79468fa136a89c5f0b2876e7093e3b04 100644 (file)
@@ -235,6 +235,7 @@ struct rspamd_main {
        struct rspamd_stat *stat;                                   /**< pointer to statistics                                                  */
 
        rspamd_mempool_t *server_pool;                              /**< server's memory pool                                                   */
+       rspamd_mempool_mutex_t *start_mtx;                          /**< server is starting up                                                  */
        GHashTable *workers;                                        /**< workers pool indexed by pid                    */
        GHashTable *spairs;                                         /**< socket pairs requested by workers                              */
        rspamd_logger_t *logger;