summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2005-09-29 04:08:18 +0000
committerKevin P. Fleming <kpfleming@digium.com>2005-09-29 04:08:18 +0000
commit91b72f5ff09530ceb5843552df610c7444001217 (patch)
tree975a433a54586c001a70023396bccce97f5732f6 /utils.c
parent3b7332c5e6b72d202d63ee14071a60338647b2a1 (diff)
ensure scheduling priority is inherited into new threads (issue #5293)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6692 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'utils.c')
-rwxr-xr-xutils.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index bb3a3e561..79d733605 100755
--- a/utils.c
+++ b/utils.c
@@ -475,6 +475,19 @@ int ast_pthread_create_stack(pthread_t *thread, pthread_attr_t *attr, void *(*st
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);