FS-7969 #resolve [Freeswitch segfaults due to pthread_setschedparam() on a thread that has exited] #comment please test this fix which was verified working

This commit is contained in:
Anthony Minessale 2015-08-19 11:42:11 -05:00
parent fa8f304248
commit f43510f243
3 changed files with 19 additions and 13 deletions

View File

@ -1 +1 @@
Tue Aug 27 13:58:18 EDT 2013
Wed Aug 19 11:38:49 CDT 2015

View File

@ -55,6 +55,7 @@ struct apr_thread_t {
void *data;
apr_thread_start_t func;
apr_status_t exitval;
int priority;
};
struct apr_threadattr_t {

View File

@ -135,6 +135,19 @@ APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr,
static void *dummy_worker(void *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);
}
@ -174,19 +187,11 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new,
return stat;
}
if (attr && attr->priority) {
(*new)->priority = attr->priority;
}
if ((stat = pthread_create(&tt, temp, dummy_worker, (*new))) == 0) {
#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
*(*new)->td = tt;
return APR_SUCCESS;