good for merge On Mon, 2010-01-11 at 12:33 +0100, Jan Friesse wrote: > Releated to https://bugzilla.redhat.com/show_bug.cgi?id=549374. > > This patch: > - allows to have some spaces before # > - make function which parses log destinations (remove code duplicity) > - clarify man page > > Regards, > Honza > plain text document attachment (549374-take2.patch) > commit c9c3935fac03ae99ac260a7372fd54518ffac097 > Author: Jan Friesse <[email protected]> > Date: Wed Jan 6 18:16:27 2010 +0100 > > Solution for RHBZ#549374 > > diff --git a/trunk/exec/coroparse.c b/trunk/exec/coroparse.c > index ba7e954..29e18a9 100644 > --- a/trunk/exec/coroparse.c > +++ b/trunk/exec/coroparse.c > @@ -115,6 +115,7 @@ static int parse_section(FILE *fp, > char line[512]; > int i; > char *loc; > + int ignore_line; > > while (fgets (line, sizeof (line), fp)) { > if (strlen(line) > 0) { > @@ -133,10 +134,20 @@ static int parse_section(FILE *fp, > break; > } > } > + > + ignore_line = 1; > + for (i = 0; i < strlen (line); i++) { > + if (line[i] != '\t' && line[i] != ' ') { > + if (line[i] != '#') > + ignore_line = 0; > + > + break; > + } > + } > /* > * Clear out comments and empty lines > */ > - if (line[0] == '#' || line[0] == '\0') { > + if (ignore_line) { > continue; > } > > diff --git a/trunk/exec/mainconfig.c b/trunk/exec/mainconfig.c > index 5cc864d..c35ba72 100644 > --- a/trunk/exec/mainconfig.c > +++ b/trunk/exec/mainconfig.c > @@ -255,6 +255,53 @@ parse_error: > return (-1); > } > > +static int corosync_main_config_log_destination_set ( > + struct objdb_iface_ver0 *objdb, > + hdb_handle_t object_handle, > + const char *subsys, > + const char **error_string, > + const char *objdb_key, > + unsigned int mode_mask, > + char deprecated, > + const char *replacement) > +{ > + static char formatted_error_reason[128]; > + char *value; > + unsigned int mode; > + > + if (!objdb_get_string (objdb, object_handle, objdb_key, &value)) { > + if (deprecated) { > + log_printf(LOGSYS_LEVEL_WARNING, > + "Warning: the %s config paramater has been obsoleted." > + " See corosync.conf man page %s directive.", > + objdb_key, replacement); > + } > + > + if (strcmp (value, "yes") == 0) { > + mode |= mode_mask; > + if (logsys_config_mode_set(subsys, mode) < 0) { > + sprintf (formatted_error_reason, "unable to set > mode %s", objdb_key); > + *error_string = formatted_error_reason; > + return -1; > + } > + } else > + if (strcmp (value, "no") == 0) { > + mode &= ~mode_mask; > + if (logsys_config_mode_set(subsys, mode) < 0) { > + sprintf (formatted_error_reason, "unable to > unset mode %s", objdb_key); > + *error_string = formatted_error_reason; > + return -1; > + } > + } else { > + sprintf (formatted_error_reason, "unknown value for > %s", objdb_key); > + *error_string = formatted_error_reason; > + return -1; > + } > + } > + > + return 0; > +} > + > static int corosync_main_config_set ( > struct objdb_iface_ver0 *objdb, > hdb_handle_t object_handle, > @@ -287,90 +334,21 @@ static int corosync_main_config_set ( > goto parse_error; > } > > - if (!objdb_get_string (objdb,object_handle, "to_file", &value)) { > - > - log_printf(LOGSYS_LEVEL_WARNING, > - "Warning: the to_file config paramater has been obsoleted." > - " See corosync.conf man page to_logfile directive."); > - > - if (strcmp (value, "yes") == 0) { > - mode |= LOGSYS_MODE_OUTPUT_FILE; > - if (logsys_config_mode_set(subsys, mode) < 0) { > - error_reason = "unable to set mode to_file"; > - goto parse_error; > - } > - } else > - if (strcmp (value, "no") == 0) { > - mode &= ~LOGSYS_MODE_OUTPUT_FILE; > - if (logsys_config_mode_set(subsys, mode) < 0) { > - error_reason = "unable to unset mode to_file"; > - goto parse_error; > - } > - } else { > - error_reason = "unknown value for to_file"; > - goto parse_error; > - } > - } > + if (corosync_main_config_log_destination_set (objdb, object_handle, > subsys, &error_reason, > + "to_logfile", LOGSYS_MODE_OUTPUT_FILE, 0, NULL) != 0) > + goto parse_error; > > - if (!objdb_get_string (objdb,object_handle, "to_logfile", &value)) { > - if (strcmp (value, "yes") == 0) { > - mode |= LOGSYS_MODE_OUTPUT_FILE; > - if (logsys_config_mode_set(subsys, mode) < 0) { > - error_reason = "unable to set mode to_logfile"; > - goto parse_error; > - } > - } else > - if (strcmp (value, "no") == 0) { > - mode &= ~LOGSYS_MODE_OUTPUT_FILE; > - if (logsys_config_mode_set(subsys, mode) < 0) { > - error_reason = "unable to unset mode > to_logfile"; > - goto parse_error; > - } > - } else { > - error_reason = "unknown value for to_logfile"; > - goto parse_error; > - } > - } > + if (corosync_main_config_log_destination_set (objdb, object_handle, > subsys, &error_reason, > + "to_stderr", LOGSYS_MODE_OUTPUT_STDERR, 0, NULL) != 0) > + goto parse_error; > > - if (!objdb_get_string (objdb,object_handle, "to_syslog", &value)) { > - if (strcmp (value, "yes") == 0) { > - mode |= LOGSYS_MODE_OUTPUT_SYSLOG; > - if (logsys_config_mode_set(subsys, mode) < 0) { > - error_reason = "unable to set mode to_syslog"; > - goto parse_error; > - } > - } else > - if (strcmp (value, "no") == 0) { > - mode &= ~LOGSYS_MODE_OUTPUT_SYSLOG; > - if (logsys_config_mode_set(subsys, mode) < 0) { > - error_reason = "unable to unset mode to_syslog"; > - goto parse_error; > - } > - } else { > - error_reason = "unknown value for to_syslog"; > - goto parse_error; > - } > - } > + if (corosync_main_config_log_destination_set (objdb, object_handle, > subsys, &error_reason, > + "to_syslog", LOGSYS_MODE_OUTPUT_SYSLOG, 0, NULL) != 0) > + goto parse_error; > > - if (!objdb_get_string (objdb,object_handle, "to_stderr", &value)) { > - if (strcmp (value, "yes") == 0) { > - mode |= LOGSYS_MODE_OUTPUT_STDERR; > - if (logsys_config_mode_set(subsys, mode) < 0) { > - error_reason = "unable to set mode to_stderr"; > - goto parse_error; > - } > - } else > - if (strcmp (value, "no") == 0) { > - mode &= ~LOGSYS_MODE_OUTPUT_STDERR; > - if (logsys_config_mode_set(subsys, mode) < 0) { > - error_reason = "unable to unset mode to_stderr"; > - goto parse_error; > - } > - } else { > - error_reason = "unknown value for to_syslog"; > - goto parse_error; > - } > - } > + if (corosync_main_config_log_destination_set (objdb, object_handle, > subsys, &error_reason, > + "to_file", LOGSYS_MODE_OUTPUT_FILE, 1, "to_logfile") != 0) > + goto parse_error; > > if (!objdb_get_string (objdb,object_handle, "syslog_facility", &value)) > { > int syslog_facility; > diff --git a/trunk/man/corosync.conf.5 b/trunk/man/corosync.conf.5 > index 6abe5c4..3f8f150 100644 > --- a/trunk/man/corosync.conf.5 > +++ b/trunk/man/corosync.conf.5 > @@ -41,11 +41,9 @@ corosync.conf - corosync executive configuration file > > .SH DESCRIPTION > The corosync.conf instructs the corosync executive about various parameters > -needed to control the corosync executive. The configuration file consists of > -bracketed top level directives. The possible directive choices are > -.IR "totem { } , logging { }. It is also possible to specify the top level > -parameter compatibility. > - These directives are described below. > +needed to control the corosync executive. Empty lines and lines starting > with > +# character are ignored. The configuration file consists of bracketed top > level > +directives. The possible directive choices are: > > .TP > totem { } > @@ -59,12 +57,12 @@ This top level directive contains configuration options > for the event service. > > .PP > .PP > -The > -.B compatibility > -directive indicates the level of compatibility requested by the user. The > +It is also possible to specify the top level parameter > +.B compatibility. > +This directive indicates the level of compatibility requested by the user. > The > option whitetank can be specified to remain backward compatable with > openais-0.80.z. The option none can be specified to only be compatable > -with corsoync-1.Y.Z. Extra processing during configuration changes is > +with corosync-1.Y.Z. Extra processing during configuration changes is > required to remain backward compatable. > > The default is whitetank. (backwards compatibility) > _______________________________________________ > Openais mailing list > [email protected] > https://lists.linux-foundation.org/mailman/listinfo/openais
_______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
