The log manager is initialized only once and skygw_log_sync_all now checks if the log manager has been successfully started before interacting with the log manager
This commit is contained in:
Markus Makela 2015-09-21 17:07:37 +03:00
parent 11c8ef5b92
commit 338b870cd1
2 changed files with 19 additions and 5 deletions

View File

@ -109,6 +109,10 @@ static bool flushall_done_flag;
static int default_log_augmentation = 0;
static int log_augmentation = default_log_augmentation;
/** This is used to detect if the initialization of the log manager has failed
* and that it isn't initialized again after a failure has occurred. */
static bool fatal_error = false;
/** Writer thread structure */
struct filewriter_st {
#if defined(SS_DEBUG)
@ -1681,7 +1685,7 @@ static bool logmanager_register(
* and its members which would probabaly lead to NULL pointer
* reference.
*/
if (!writep) {
if (!writep || fatal_error) {
succp = false;
goto return_succp;
}
@ -1709,6 +1713,11 @@ static bool logmanager_register(
}
return_succp:
if(!succp)
{
fatal_error = true;
}
release_lock(&lmlock);
return succp;
}
@ -3232,9 +3241,15 @@ void flushall_logfiles(bool flush)
void skygw_log_sync_all(void)
{
if(!use_stdout)skygw_log_write(LOGFILE_TRACE,"Starting log flushing to disk.");
flushall_logfiles(true);
skygw_message_send(lm->lm_logmes);
skygw_message_wait(lm->lm_clientmes);
/** If initialization of the log manager has not been done, lm pointer can be
* NULL. */
if(lm)
{
flushall_logfiles(true);
skygw_message_send(lm->lm_logmes);
skygw_message_wait(lm->lm_clientmes);
}
}
/**

View File

@ -1648,7 +1648,6 @@ int main(int argc, char **argv)
if (!resolve_maxscale_conf_fname(&cnf_file_path, pathbuf, cnf_file_arg))
{
ss_dassert(cnf_file_path == NULL);
rc = MAXSCALE_BADCONFIG;
goto return_main;
}