Sfoglia il codice sorgente

logsys: Handle full /dev/shm correctly

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@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse 12 anni fa
parent
commit
095a114ab8
2 ha cambiato i file con 24 aggiunte e 10 eliminazioni
  1. 2 0
      exec/logsys.c
  2. 22 10
      include/corosync/engine/logsys.h

+ 2 - 0
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);

+ 22 - 10
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);					\
 	}								\
 }