[asterisk-commits] tilghman: branch 1.2 r60849 - in /branches/1.2: asterisk.c include/asterisk.h

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Apr 8 19:49:07 MST 2007


Author: tilghman
Date: Sun Apr  8 21:49:06 2007
New Revision: 60849

URL: http://svn.digium.com/view/asterisk?view=rev&rev=60849
Log:
Don't check for error when lowering priority (according to the manpage, it should never happen anyway).  It might could happen, though, if another thread messed with the priority, so safeguard against that (reported via -dev list).

Modified:
    branches/1.2/asterisk.c
    branches/1.2/include/asterisk.h

Modified: branches/1.2/asterisk.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/asterisk.c?view=diff&rev=60849&r1=60848&r2=60849
==============================================================================
--- branches/1.2/asterisk.c (original)
+++ branches/1.2/asterisk.c Sun Apr  8 21:49:06 2007
@@ -795,6 +795,7 @@
 	struct sched_param sched;
 	memset(&sched, 0, sizeof(sched));
 #ifdef __linux__
+#undef sched_setscheduler
 	if (pri) {  
 		sched.sched_priority = 10;
 		if (sched_setscheduler(0, SCHED_RR, &sched)) {
@@ -805,12 +806,11 @@
 				ast_verbose("Set to realtime thread\n");
 	} else {
 		sched.sched_priority = 0;
-		if (sched_setscheduler(0, SCHED_OTHER, &sched)) {
-			ast_log(LOG_WARNING, "Unable to set normal priority\n");
-			return -1;
-		}
+		/* According to the manpage, this can never fail, with these parameters. */
+		sched_setscheduler(0, SCHED_OTHER, &sched);
 	}
 #else
+#undef setpriority
 	if (pri) {
 		if (setpriority(PRIO_PROCESS, 0, -10) == -1) {
 			ast_log(LOG_WARNING, "Unable to set high priority\n");
@@ -819,10 +819,8 @@
 			if (option_verbose)
 				ast_verbose("Set to high priority\n");
 	} else {
-		if (setpriority(PRIO_PROCESS, 0, 0) == -1) {
-			ast_log(LOG_WARNING, "Unable to set normal priority\n");
-			return -1;
-		}
+		/* According to the manpage, this can never fail, with these parameters. */
+		setpriority(PRIO_PROCESS, 0, 0);
 	}
 #endif
 	return 0;

Modified: branches/1.2/include/asterisk.h
URL: http://svn.digium.com/view/asterisk/branches/1.2/include/asterisk.h?view=diff&rev=60849&r1=60848&r2=60849
==============================================================================
--- branches/1.2/include/asterisk.h (original)
+++ branches/1.2/include/asterisk.h Sun Apr  8 21:49:06 2007
@@ -21,6 +21,8 @@
 #define DEFAULT_LANGUAGE "en"
 
 #define AST_CONFIG_MAX_PATH 255
+#define	setpriority	__PLEASE_USE_ast_set_priority_INSTEAD_OF_setpriority__
+#define	sched_setscheduler	__PLEASE_USE_ast_set_priority_INSTEAD_OF_sched_setscheduler__
 
 /* provided in asterisk.c */
 extern char ast_config_AST_CONFIG_DIR[AST_CONFIG_MAX_PATH];



More information about the asterisk-commits mailing list