[Asterisk-cvs] asterisk utils.c,1.70,1.71

kpfleming kpfleming
Thu Sep 29 00:11:42 CDT 2005


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv9771

Modified Files:
	utils.c 
Log Message:
ensure scheduling priority is inherited into new threads (issue #5293)


Index: utils.c
===================================================================
RCS file: /usr/cvsroot/asterisk/utils.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- utils.c	23 Sep 2005 02:57:14 -0000	1.70
+++ utils.c	29 Sep 2005 04:08:18 -0000	1.71
@@ -475,6 +475,19 @@
 		pthread_attr_init(&lattr);
 		attr = &lattr;
 	}
+#ifdef __linux__
+	/* On Linux, pthread_attr_init() defaults to PTHREAD_EXPLICIT_SCHED,
+	   which is kind of useless. Change this here to
+	   PTHREAD_INHERIT_SCHED; that way the -p option to set realtime
+	   priority will propagate down to new threads by default.
+	   This does mean that callers cannot set a different priority using
+	   PTHREAD_EXPLICIT_SCHED in the attr argument; instead they must set
+	   the priority afterwards with pthread_setschedparam(). */
+	errno = pthread_attr_setinheritsched(attr, PTHREAD_INHERIT_SCHED);
+	if (errno)
+		ast_log(LOG_WARNING, "pthread_attr_setinheritsched returned non-zero: %s\n", strerror(errno));
+#endif
+
 	if (!stacksize)
 		stacksize = AST_STACKSIZE;
 	errno = pthread_attr_setstacksize(attr, stacksize);




More information about the svn-commits mailing list