1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
From f43510f2430150b7f425d614f6bc605fcd3ed0ce Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthm@freeswitch.org>
Date: Wed, 19 Aug 2015 11:42:11 -0500
Subject: [PATCH] FS-7969 #resolve [Freeswitch segfaults due to
pthread_setschedparam() on a thread that has exited] #comment please test
this fix which was verified working
---
libs/apr/.update | 2 +-
libs/apr/include/arch/unix/apr_arch_threadproc.h | 1 +
libs/apr/threadproc/unix/thread.c | 29 ++++++++++++++----------
3 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/libs/apr/.update b/libs/apr/.update
index 1aeaab4..6e68952 100644
--- a/libs/apr/.update
+++ b/libs/apr/.update
@@ -1 +1 @@
-Tue Aug 27 13:58:18 EDT 2013
+Wed Aug 19 11:38:49 CDT 2015
diff --git a/libs/apr/include/arch/unix/apr_arch_threadproc.h b/libs/apr/include/arch/unix/apr_arch_threadproc.h
index bd9359a..348c6c5 100644
--- a/libs/apr/include/arch/unix/apr_arch_threadproc.h
+++ b/libs/apr/include/arch/unix/apr_arch_threadproc.h
@@ -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 {
diff --git a/libs/apr/threadproc/unix/thread.c b/libs/apr/threadproc/unix/thread.c
index 8859e79..165dddc 100644
--- a/libs/apr/threadproc/unix/thread.c
+++ b/libs/apr/threadproc/unix/thread.c
@@ -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, ¶m);
+ param.sched_priority = thread->priority;
+ pthread_setschedparam(tt, policy, ¶m);
+ }
+#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, ¶m);
- param.sched_priority = attr->priority;
- pthread_setschedparam(tt, policy, ¶m);
- }
-#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;
--
2.5.0
|