diff options
-rw-r--r-- | src/libserver/logger/logger.c | 4 | ||||
-rw-r--r-- | src/rspamd.c | 11 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/libserver/logger/logger.c b/src/libserver/logger/logger.c index 4e48eae4e..789a41af2 100644 --- a/src/libserver/logger/logger.c +++ b/src/libserver/logger/logger.c @@ -182,8 +182,6 @@ rspamd_log_open_specific (rspamd_mempool_t *pool, rspamd_logger_t *logger; GError *err = NULL; - g_assert (emergency_logger != NULL); - if (pool) { logger = rspamd_mempool_alloc0 (pool, sizeof (rspamd_logger_t)); logger->mtx = rspamd_mempool_get_mutex (pool); @@ -233,7 +231,7 @@ rspamd_log_open_specific (rspamd_mempool_t *pool, logger->ops.specific = logger->ops.init (logger, cfg, uid, gid, &err); - if (logger->ops.specific == NULL) { + if (emergency_logger && logger->ops.specific == NULL) { rspamd_common_log_function (emergency_logger, G_LOG_LEVEL_CRITICAL, "logger", NULL, G_STRFUNC, "cannot open specific logger: %e", err); diff --git a/src/rspamd.c b/src/rspamd.c index 02a903479..3a889ec69 100644 --- a/src/rspamd.c +++ b/src/rspamd.c @@ -1335,9 +1335,14 @@ main (gint argc, gchar **argv, gchar **env) msg_info_main ("libottery prf: %s", ottery_get_impl_name ()); /* Daemonize */ - if (!no_fork && daemon (0, 0) == -1) { - rspamd_fprintf (stderr, "Cannot daemonize\n"); - exit (-errno); + if (!no_fork) { + if (daemon (0, 0) == -1) { + msg_err_main ("cannot daemonize: %s", strerror (errno)); + exit (-errno); + } + + /* Close emergency logger */ + rspamd_log_close (rspamd_log_emergency_logger ()); } /* Write info */ |