From 32c4e605169ba28cedafded10c20345bb791c14d Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 30 Aug 2018 14:59:34 +0300 Subject: [PATCH] Do not re-initialize the log Do not re-initialize the log without it having been finished in between. --- server/core/gateway.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/core/gateway.cc b/server/core/gateway.cc index 4164ffae8..2ee45dce4 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -753,10 +753,8 @@ static void print_log_n_stderr( { if (do_log) { - static bool log_is_inited = false; - if (log_is_inited || init_log()) + if (mxb_log_inited() || init_log()) { - log_is_inited = true; MXS_ERROR("%s%s%s%s", logstr, eno == 0 ? "" : " (", @@ -1860,6 +1858,14 @@ int main(int argc, char **argv) goto return_main; } + if (mxb_log_inited()) + { + // If the log was inited due to some error logging *and* we did not exit, + // we need to close it so that it can be opened again, this time with + // the final settings. + mxs_log_finish(); + } + if (!init_log()) { rc = MAXSCALE_BADCONFIG;