提交 d7f3c5a7 authored 作者: Anthony Minessale's avatar Anthony Minessale 提交者: Michael Jerris

FS-7969: Freeswitch segfaults due to pthread_setschedparam() on a thread that…

FS-7969: Freeswitch segfaults due to pthread_setschedparam() on a thread that has exited] #comment please test this fix which was verified working
上级 23fbdcab
Tue Aug 27 13:58:18 EDT 2013 Wed Aug 19 11:38:49 CDT 2015
...@@ -55,6 +55,7 @@ struct apr_thread_t { ...@@ -55,6 +55,7 @@ struct apr_thread_t {
void *data; void *data;
apr_thread_start_t func; apr_thread_start_t func;
apr_status_t exitval; apr_status_t exitval;
int priority;
}; };
struct apr_threadattr_t { struct apr_threadattr_t {
......
...@@ -135,6 +135,19 @@ APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, ...@@ -135,6 +135,19 @@ APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr,
static void *dummy_worker(void *opaque) static void *dummy_worker(void *opaque)
{ {
apr_thread_t *thread = (apr_thread_t*)opaque; apr_thread_t *thread = (apr_thread_t*)opaque;
#ifdef HAVE_PTHREAD_SETSCHEDPARAM
if (thread->priority) {
int policy;
struct sched_param param = { 0 };
pthread_t tt = pthread_self();
pthread_getschedparam(tt, &policy, &param);
param.sched_priority = thread->priority;
pthread_setschedparam(tt, policy, &param);
}
#endif
return thread->func(thread, thread->data); return thread->func(thread, thread->data);
} }
...@@ -174,19 +187,11 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, ...@@ -174,19 +187,11 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new,
return stat; return stat;
} }
if ((stat = pthread_create(&tt, temp, dummy_worker, (*new))) == 0) { if (attr && attr->priority) {
(*new)->priority = attr->priority;
#ifdef HAVE_PTHREAD_SETSCHEDPARAM }
if (attr && attr->priority) {
int policy;
struct sched_param param = { 0 };
pthread_getschedparam(tt, &policy, &param);
param.sched_priority = attr->priority;
pthread_setschedparam(tt, policy, &param);
}
#endif
if ((stat = pthread_create(&tt, temp, dummy_worker, (*new))) == 0) {
*(*new)->td = tt; *(*new)->td = tt;
return APR_SUCCESS; return APR_SUCCESS;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论