ACK to both patches. Fabio On 9/5/2012 5:34 PM, Jan Friesse wrote: > Previous two log releated patches tried to solve few problems with > threaded libqb, but introduced regressions when running in daemon mode. > > This patch takes bigger hammer and hopefully solves all problems. > > Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx> > --- > exec/logsys.c | 33 ++++++++++++++++++++++++++++----- > exec/main.c | 5 ++++- > include/corosync/logsys.h | 2 ++ > 3 files changed, 34 insertions(+), 6 deletions(-) > > diff --git a/exec/logsys.c b/exec/logsys.c > index 74d257d..baaae51 100644 > --- a/exec/logsys.c > +++ b/exec/logsys.c > @@ -117,6 +117,8 @@ static void logsys_file_format_get(char* file_format, int buf_len); > > static char *format_buffer=NULL; > > +static int logsys_thread_started = 0; > + > static int _logsys_config_subsys_get_unlocked (const char *subsys) > { > unsigned int i; > @@ -230,7 +232,9 @@ static int logsys_config_file_set_unlocked ( > qb_log_ctl(logsys_loggers[subsysid].target_id, > QB_LOG_CONF_ENABLED, > (logsys_loggers[subsysid].mode & LOGSYS_MODE_OUTPUT_FILE)); > - qb_log_ctl(logsys_loggers[subsysid].target_id, QB_LOG_CONF_THREADED, QB_TRUE); > + if (logsys_thread_started) { > + qb_log_ctl(logsys_loggers[subsysid].target_id, QB_LOG_CONF_THREADED, QB_TRUE); > + } > > return (0); > } > @@ -292,7 +296,6 @@ int _logsys_system_setup( > int i; > int32_t fidx; > char tempsubsys[LOGSYS_MAX_SUBSYS_NAMELEN]; > - int res; > > if ((mainsystem == NULL) || > (strlen(mainsystem) >= LOGSYS_MAX_SUBSYS_NAMELEN)) { > @@ -357,7 +360,6 @@ int _logsys_system_setup( > } else { > qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_ENABLED, QB_FALSE); > } > - qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_THREADED, QB_TRUE); > qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_PRIORITY_BUMP, LOG_INFO - LOG_DEBUG); > > qb_log_filter_ctl(QB_LOG_BLACKBOX, QB_LOG_FILTER_ADD, > @@ -386,11 +388,10 @@ int _logsys_system_setup( > _logsys_config_apply_per_subsys(i); > } > } > - res = qb_log_thread_start(); > > pthread_mutex_unlock (&logsys_config_mutex); > > - return (res); > + return (0); > } > > > @@ -791,3 +792,25 @@ int logsys_priority_id_get (const char *name) > } > return (-1); > } > + > +int logsys_thread_start (void) > +{ > + int i; > + int err; > + > + err = qb_log_thread_start(); > + if (err != 0) { > + return (err); > + } > + > + qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_THREADED, QB_TRUE); > + for (i = 0; i <= LOGSYS_MAX_SUBSYS_COUNT; i++) { > + if (logsys_loggers[i].target_id > 0) { > + qb_log_ctl(logsys_loggers[i].target_id, QB_LOG_CONF_THREADED, QB_TRUE); > + } > + } > + > + logsys_thread_started = 1; > + > + return (0); > +} > diff --git a/exec/main.c b/exec/main.c > index 6cbfef6..0fa256e 100644 > --- a/exec/main.c > +++ b/exec/main.c > @@ -1172,7 +1172,10 @@ int main (int argc, char **argv, char **envp) > if (background) { > corosync_tty_detach (); > } > - qb_log_thread_start(); > + if (logsys_thread_start() != 0) { > + log_printf (LOGSYS_LEVEL_ERROR, "Can't initialize log thread"); > + corosync_exit_error (COROSYNC_DONE_LOGCONFIGREAD); > + } > > if ((flock_err = corosync_flock (corosync_lock_file, getpid ())) != COROSYNC_DONE_EXIT) { > corosync_exit_error (flock_err); > diff --git a/include/corosync/logsys.h b/include/corosync/logsys.h > index 5c37454..fcce049 100644 > --- a/include/corosync/logsys.h > +++ b/include/corosync/logsys.h > @@ -165,6 +165,8 @@ extern int _logsys_config_subsys_get ( > > extern int _logsys_subsys_create (const char *subsys, const char *filename); > > +extern int logsys_thread_start (void); > + > static int logsys_subsys_id __attribute__((unused)) = LOGSYS_MAX_SUBSYS_COUNT; > > #define LOGSYS_DECLARE_SYSTEM(name,mode,syslog_facility,syslog_priority)\ > _______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss