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

Make realtime scheduling optional not the default.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
Angus Salkeld 14 лет назад
Родитель
Сommit
cdf5e95ab4
3 измененных файлов с 26 добавлено и 8 удалено
  1. 6 0
      configure.ac
  2. 15 6
      exec/main.c
  3. 5 2
      man/corosync.8

+ 6 - 0
configure.ac

@@ -73,6 +73,12 @@ AC_CHECK_LIB([socket], [socket])
 AC_CHECK_LIB([nsl], [t_open])
 AC_CHECK_LIB([rt], [sched_getscheduler])
 PKG_CHECK_MODULES([LIBQB], [libqb])
+AC_CHECK_LIB([qb], [qb_log_thread_priority_set], \
+	     have_qb_log_thread_priority_set="yes", \
+	     have_qb_log_thread_priority_set="no")
+if test "x${have_qb_log_thread_priority_set}" = xyes; then
+	AC_DEFINE_UNQUOTED([HAVE_QB_LOG_THREAD_PRIORITY_SET], 1, [have qb_log_thread_priority_set])
+fi
 
 # Checks for header files.
 AC_FUNC_ALLOCA

+ 15 - 6
exec/main.c

@@ -1004,13 +1004,19 @@ static void corosync_setscheduler (void)
 				global_sched_param.sched_priority);
 
 			global_sched_param.sched_priority = 0;
-			logsys_thread_priority_set (SCHED_OTHER, NULL, 1);
+#ifdef HAVE_QB_LOG_THREAD_PRIORITY_SET
+			qb_log_thread_priority_set (SCHED_OTHER, 0);
+#endif
 		} else {
 
 			/*
 			 * Turn on SCHED_RR in logsys system
 			 */
-			res = logsys_thread_priority_set (SCHED_RR, &global_sched_param, 10);
+#ifdef HAVE_QB_LOG_THREAD_PRIORITY_SET
+			res = qb_log_thread_priority_set (SCHED_RR, sched_priority);
+#else
+			res = -1;
+#endif
 			if (res == -1) {
 				log_printf (LOGSYS_LEVEL_ERROR,
 					    "Could not set logsys thread priority."
@@ -1262,9 +1268,9 @@ int main (int argc, char **argv, char **envp)
 	/* default configuration
 	 */
 	background = 1;
-	setprio = 1;
+	setprio = 0;
 
-	while ((ch = getopt (argc, argv, "fpv")) != EOF) {
+	while ((ch = getopt (argc, argv, "fprv")) != EOF) {
 
 		switch (ch) {
 			case 'f':
@@ -1272,7 +1278,9 @@ int main (int argc, char **argv, char **envp)
 				logsys_config_mode_set (NULL, LOGSYS_MODE_OUTPUT_STDERR|LOGSYS_MODE_THREADED|LOGSYS_MODE_FORK);
 				break;
 			case 'p':
-				setprio = 0;
+				break;
+			case 'r':
+				setprio = 1;
 				break;
 			case 'v':
 				printf ("Corosync Cluster Engine, version '%s'\n", VERSION);
@@ -1284,7 +1292,8 @@ int main (int argc, char **argv, char **envp)
 				fprintf(stderr, \
 					"usage:\n"\
 					"        -f     : Start application in foreground.\n"\
-					"        -p     : Do not set process priority.    \n"\
+					"        -p     : Does nothing.    \n"\
+					"        -r     : Set round robin realtime scheduling \n"\
 					"        -v     : Display version and SVN revision of Corosync and exit.\n");
 				return EXIT_FAILURE;
 		}

+ 5 - 2
man/corosync.8

@@ -35,7 +35,7 @@
 .SH NAME
 corosync \- The Corosync Cluster Engine.
 .SH SYNOPSIS
-.B "corosync [\-f] [\-p] [\-v]"
+.B "corosync [\-f] [\-p] [\-r] [\-v]"
 .SH DESCRIPTION
 .B corosync
 Corosync provides clustering infracture such as membership, messaging and quorum.
@@ -45,7 +45,10 @@ Corosync provides clustering infracture such as membership, messaging and quorum
 Start application in foreground.
 .TP
 .B -p
-Do not set process priority.    
+Does nothing (was: "Do not set process priority" - this is now the default).
+.TP
+.B -r
+Set round robin realtime scheduling.
 .TP
 .B -v
 Display version and SVN revision of Corosync and exit.