Просмотр исходного кода

Correction to segv handler
Added abort handler


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1318 fd59a12c-fef9-0310-b244-a6a79926bd2f

Hans Feldt 19 лет назад
Родитель
Сommit
ea286d6457
2 измененных файлов с 36 добавлено и 27 удалено
  1. 11 3
      exec/main.c
  2. 25 24
      exec/print.c

+ 11 - 3
exec/main.c

@@ -108,7 +108,16 @@ static void sigusr2_handler (int num)
 
 
 static void sigsegv_handler (int num)
 static void sigsegv_handler (int num)
 {
 {
-	log_atsegv ();
+	signal (SIGSEGV, SIG_DFL);
+	log_flush ();
+	raise (SIGSEGV);
+}
+
+static void sigabrt_handler (int num)
+{
+	signal (SIGABRT, SIG_DFL);
+	log_flush ();
+	raise (SIGABRT);
 }
 }
 
 
 struct totem_ip_address *this_ip;
 struct totem_ip_address *this_ip;
@@ -421,10 +430,9 @@ int main (int argc, char **argv)
 	totemip_localhost(AF_INET, &this_non_loopback_ip);
 	totemip_localhost(AF_INET, &this_non_loopback_ip);
 
 
 	signal (SIGINT, sigintr_handler);
 	signal (SIGINT, sigintr_handler);
-
 	signal (SIGUSR2, sigusr2_handler);
 	signal (SIGUSR2, sigusr2_handler);
-
 	signal (SIGSEGV, sigsegv_handler);
 	signal (SIGSEGV, sigsegv_handler);
+	signal (SIGABRT, sigabrt_handler);
 
 
 	openais_timer_init (
 	openais_timer_init (
 		serialize_mutex_lock,
 		serialize_mutex_lock,

+ 25 - 24
exec/print.c

@@ -333,7 +333,6 @@ int log_setup (char **error_string, struct main_config *config)
 		NULL,
 		NULL,
 		log_printf_worker_fn);
 		log_printf_worker_fn);
 
 
-	log_setup_called = 1;
 
 
 	/*
 	/*
 	** Flush what we have buffered
 	** Flush what we have buffered
@@ -343,6 +342,9 @@ int log_setup (char **error_string, struct main_config *config)
 	internal_log_printf(__FILE__, __LINE__, LOG_LEVEL_DEBUG, "log setup\n");
 	internal_log_printf(__FILE__, __LINE__, LOG_LEVEL_DEBUG, "log setup\n");
 
 
 	atexit (log_atexit);
 	atexit (log_atexit);
+
+	log_setup_called = 1;
+
 	return (0);
 	return (0);
 }
 }
 
 
@@ -389,25 +391,6 @@ void trace (char *file, int line, int tag, int id, char *format, ...)
 	}
 	}
 }
 }
 
 
-void log_flush(void)
-{
-	struct log_entry *entry = head;
-	struct log_entry *tmp;
-
-	/* do not buffer these printouts */
-	logmode &= ~LOG_MODE_BUFFER;
-
-	while (entry) {
-		internal_log_printf(entry->file, entry->line,
-			entry->level, entry->str);
-		tmp = entry;
-		entry = entry->next;
-		free(tmp);
-	}
-
-	head = tail = NULL;
-}
-
 static void log_atexit (void)
 static void log_atexit (void)
 {
 {
 	if (log_setup_called) {
 	if (log_setup_called) {
@@ -415,9 +398,27 @@ static void log_atexit (void)
 	}
 	}
 }
 }
 
 
-void log_atsegv (void)
+void log_flush (void)
 {
 {
-	log_setup_called = 0;
-	worker_thread_group_exit (&log_thread_group);
-	worker_thread_group_atsegv (&log_thread_group);
+	if (log_setup_called) {
+		log_setup_called = 0;
+		worker_thread_group_exit (&log_thread_group);
+		worker_thread_group_atsegv (&log_thread_group);
+	} else {
+		struct log_entry *entry = head;
+		struct log_entry *tmp;
+
+		/* do not buffer these printouts */
+		logmode &= ~LOG_MODE_BUFFER;
+
+		while (entry) {
+			internal_log_printf(entry->file, entry->line,
+				entry->level, entry->str);
+			tmp = entry;
+			entry = entry->next;
+			free(tmp);
+		}
+
+		head = tail = NULL;
+	}
 }
 }