ACK On 25/09/13 14:50, Jan Friesse wrote:
If /dev/shm was full, corosync was segfaulting instead of display error and exit with proper exit code (code > 127 is reserved for signals). Also when logsys is not initialized, error message was displayed only on stderr. This is not ok if corosync is running as service and solution is to send error also to syslog. Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx> --- exec/logsys.c | 2 ++ include/corosync/engine/logsys.h | 32 ++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/exec/logsys.c b/exec/logsys.c index 044de12..ec51cc3 100644 --- a/exec/logsys.c +++ b/exec/logsys.c @@ -1067,6 +1067,8 @@ int _logsys_rec_init (unsigned int fltsize) if (res == -1) { sem_destroy (&logsys_thread_start); sem_destroy (&logsys_print_finished); + + return (-1); } memset (flt_data, 0, flt_real_size * 2); diff --git a/include/corosync/engine/logsys.h b/include/corosync/engine/logsys.h index 6b26a9f..0be4a29 100644 --- a/include/corosync/engine/logsys.h +++ b/include/corosync/engine/logsys.h @@ -342,29 +342,41 @@ extern void *logsys_rec_end; __attribute__ ((constructor)) \ static void logsys_system_init (void) \ { \ + const char *error_str; \ + \ if (_logsys_system_setup (name,mode,debug,file,file_priority, \ syslog_facility,syslog_priority) < 0) { \ fprintf (stderr, \ "Unable to setup logging system: %s.\n", name); \ - exit (-1); \ + syslog (LOG_ERR, \ + "Unable to setup logging system: %s.\n", name); \ + exit (EXIT_FAILURE); \ } \ \ if (logsys_format_set (format) == -1) { \ - fprintf (stderr, \ - "Unable to setup logging format.\n"); \ - exit (-1); \ + error_str = "Unable to setup logging format."; \ + \ + fprintf (stderr, "%s\n", error_str); \ + syslog (LOG_ERR, "%s\n", error_str); \ + exit (EXIT_FAILURE); \ } \ \ if (_logsys_rec_init (fltsize) < 0) { \ - fprintf (stderr, \ - "Unable to initialize log flight recorder.\n"); \ - exit (-1); \ + error_str = "Unable to initialize log flight recorder. "\ + "The most common cause of this error is " \ + "not enough space on /dev/shm."; \ + \ + fprintf (stderr, "%s\n", error_str); \ + syslog (LOG_ERR, "%s\n", error_str); \ + exit (EXIT_FAILURE); \ } \ \ if (_logsys_wthread_create() < 0) { \ - fprintf (stderr, \ - "Unable to initialize logging thread.\n"); \ - exit (-1); \ + error_str = "Unable to initialize logging thread."; \ + \ + fprintf (stderr, "%s\n", error_str); \ + syslog (LOG_ERR, "%s\n", error_str); \ + exit (EXIT_FAILURE); \ } \ }
_______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss