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

Move corosync exit semaphore initialization

When signal is delivered before initialization of exit semaphore,
corosync will never exit. Solution is to initialize semaphore earlier.

Signed-off-by: jason <huzhijiang@gmail.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
jason 13 лет назад
Родитель
Сommit
b6aaa6e2af
1 измененных файлов с 9 добавлено и 7 удалено
  1. 9 7
      exec/main.c

+ 9 - 7
exec/main.c

@@ -1620,6 +1620,14 @@ int main (int argc, char **argv, char **envp)
 	log_printf (LOGSYS_LEVEL_NOTICE, "Corosync Cluster Engine ('%s'): started and ready to provide service.\n", VERSION);
 	log_printf (LOGSYS_LEVEL_NOTICE, "Corosync Cluster Engine ('%s'): started and ready to provide service.\n", VERSION);
 	log_printf (LOGSYS_LEVEL_INFO, "Corosync built-in features:" PACKAGE_FEATURES "\n");
 	log_printf (LOGSYS_LEVEL_INFO, "Corosync built-in features:" PACKAGE_FEATURES "\n");
 
 
+	/*
+	 * Create exit semaphore
+	 */
+	res = sem_init (&corosync_exit_sem, 0, 0);
+	if (res != 0) {
+		log_printf (LOGSYS_LEVEL_ERROR, "Corosync Executive couldn't create exit thread.\n");
+		corosync_exit_error (AIS_DONE_FATAL_ERR);
+	}
 
 
 	(void)signal (SIGINT, sigintr_handler);
 	(void)signal (SIGINT, sigintr_handler);
 	(void)signal (SIGUSR2, sigusr2_handler);
 	(void)signal (SIGUSR2, sigusr2_handler);
@@ -1803,14 +1811,8 @@ int main (int argc, char **argv, char **envp)
 // TODO what is this hack for?	usleep(totem_config.token_timeout * 2000);
 // TODO what is this hack for?	usleep(totem_config.token_timeout * 2000);
 
 
 	/*
 	/*
-	 * Create semaphore and start "exit" thread
+	 * Start "exit" thread
 	 */
 	 */
-	res = sem_init (&corosync_exit_sem, 0, 0);
-	if (res != 0) {
-		log_printf (LOGSYS_LEVEL_ERROR, "Corosync Executive couldn't create exit thread.\n");
-		corosync_exit_error (AIS_DONE_FATAL_ERR);
-	}
-
 	res = pthread_create (&corosync_exit_thread, NULL, corosync_exit_thread_handler, NULL);
 	res = pthread_create (&corosync_exit_thread, NULL, corosync_exit_thread_handler, NULL);
 	if (res != 0) {
 	if (res != 0) {
 		log_printf (LOGSYS_LEVEL_ERROR, "Corosync Executive couldn't create exit thread.\n");
 		log_printf (LOGSYS_LEVEL_ERROR, "Corosync Executive couldn't create exit thread.\n");