]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7969: Freeswitch segfaults due to pthread_setschedparam() on a thread that has...
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 19 Aug 2015 16:42:11 +0000 (11:42 -0500)
committerMichael Jerris <mike@jerris.com>
Tue, 25 Aug 2015 19:49:26 +0000 (14:49 -0500)
libs/apr/.update
libs/apr/include/arch/unix/apr_arch_threadproc.h
libs/apr/threadproc/unix/thread.c

index 1aeaab4078ae03410ee0c71f194da5ed41318d50..6e6895295d3c7dd878e7226801beeebd19987584 100644 (file)
@@ -1 +1 @@
-Tue Aug 27 13:58:18 EDT 2013
+Wed Aug 19 11:38:49 CDT 2015
index bd9359a49f80b00bb43af452325e5995e81596f9..348c6c55d37062769eb3cc9c30028b7f622a7f03 100644 (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 {
index 8859e79ac767e61a507073eb2f06a0f70443fd65..165dddc2380274b0e112e6b169c5f70870fbed7a 100644 (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 ((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
+       if (attr && attr->priority) {
+               (*new)->priority = attr->priority;
+       }
 
+    if ((stat = pthread_create(&tt, temp, dummy_worker, (*new))) == 0) {
                *(*new)->td = tt;
 
         return APR_SUCCESS;