diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-27 14:28:32 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-27 14:28:32 +0100 |
commit | fa5191e3e588fffdddd62cc3814e1fbc49bc4730 (patch) | |
tree | b9860a4dbb297a02233d67009ff3a002576638b6 /src/rspamd.c | |
parent | f03c7fe732ba335f84514bccac42d649f5c998ca (diff) | |
download | rspamd-fa5191e3e588fffdddd62cc3814e1fbc49bc4730.tar.gz rspamd-fa5191e3e588fffdddd62cc3814e1fbc49bc4730.zip |
[Fix] Do not create pid file in no-fork mode
Issue: #2118
Closes: #2118
Diffstat (limited to 'src/rspamd.c')
-rw-r--r-- | src/rspamd.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/rspamd.c b/src/rspamd.c index a44f33b6c..abc15ead9 100644 --- a/src/rspamd.c +++ b/src/rspamd.c @@ -1162,6 +1162,7 @@ main (gint argc, gchar **argv, gchar **env) struct event term_ev, int_ev, cld_ev, hup_ev, usr1_ev, control_ev; struct timeval term_tv; struct rspamd_main *rspamd_main; + gboolean skip_pid = FALSE; #if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION <= 30)) g_thread_init (NULL); @@ -1348,7 +1349,12 @@ main (gint argc, gchar **argv, gchar **env) sigaction (SIGPIPE, &sigpipe_act, NULL); if (rspamd_main->cfg->pid_file == NULL) { - msg_info("pid file is not specified, skipping writing it"); + msg_info_main ("pid file is not specified, skipping writing it"); + skip_pid = TRUE; + } + else if (no_fork) { + msg_info_main ("skip writing pid in no-fork mode"); + skip_pid = TRUE; } else if (rspamd_write_pid (rspamd_main) == -1) { msg_err_main ("cannot write pid file %s", rspamd_main->cfg->pid_file); @@ -1479,11 +1485,16 @@ main (gint argc, gchar **argv, gchar **env) } msg_info_main ("terminating..."); + 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); - rspamd_pidfile_close (rspamd_main->pfh); + + if (!skip_pid) { + rspamd_pidfile_close (rspamd_main->pfh); + } + g_free (rspamd_main); event_base_free (ev_base); |