From 917d264454c72c77990ecb980961f47daa7f77e1 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 20 Aug 2015 14:13:40 +0200 Subject: main/freeswitch: use patch from upstream for pthread priority fix and increase timeout on stop --- ...olve-Freeswitch-segfaults-due-to-pthread_.patch | 83 ++++++++++++++++++++++ main/freeswitch/APKBUILD | 16 ++--- main/freeswitch/fix-pthread-sched.patch | 38 ---------- main/freeswitch/freeswitch.initd | 2 +- 4 files changed, 92 insertions(+), 47 deletions(-) create mode 100644 main/freeswitch/0001-FS-7969-resolve-Freeswitch-segfaults-due-to-pthread_.patch delete mode 100644 main/freeswitch/fix-pthread-sched.patch (limited to 'main/freeswitch') diff --git a/main/freeswitch/0001-FS-7969-resolve-Freeswitch-segfaults-due-to-pthread_.patch b/main/freeswitch/0001-FS-7969-resolve-Freeswitch-segfaults-due-to-pthread_.patch new file mode 100644 index 0000000000..ca6f36f45e --- /dev/null +++ b/main/freeswitch/0001-FS-7969-resolve-Freeswitch-segfaults-due-to-pthread_.patch @@ -0,0 +1,83 @@ +From f43510f2430150b7f425d614f6bc605fcd3ed0ce Mon Sep 17 00:00:00 2001 +From: Anthony Minessale +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 + diff --git a/main/freeswitch/APKBUILD b/main/freeswitch/APKBUILD index c1a793f9ad..1fc2e4af4a 100644 --- a/main/freeswitch/APKBUILD +++ b/main/freeswitch/APKBUILD @@ -3,7 +3,7 @@ # Contributor: Cameron Banta pkgname=freeswitch pkgver=1.4.20 -pkgrel=1 +pkgrel=2 pkgdesc="A communications platform written in C from the ground up" url="http://www.freeswitch.org" arch="all" @@ -69,7 +69,7 @@ source="http://files.freeswitch.org/$pkgname-$pkgver.tar.xz libshout-disable-examples.patch freeswitch-mod_shout-textrels.patch system-lame.patch - fix-pthread-sched.patch + 0001-FS-7969-resolve-Freeswitch-segfaults-due-to-pthread_.patch " _builddir="$srcdir/$pkgname-$pkgver" @@ -219,11 +219,11 @@ e409b006b5dad6d8668c3e429bf20159 freeswitch-libshout-2.2.2.tar.gz 1e7f335ee00f589825ecc9affa779346 getlib.patch 0eb382f73ed393f28b8a797ebbfa608b modules.conf c608cca8ad773acebf201f581438c7e7 freeswitch.confd -d823b7fd353c9a95467e736e4a226b74 freeswitch.initd +3b0bf4847a61afa28229b58763f4c400 freeswitch.initd 90b133b14a42c86d53d5e54dcbfbaf58 libshout-disable-examples.patch 4cd4923463c89bed053e6295b5a4ec40 freeswitch-mod_shout-textrels.patch 6a6c4aba80e99c236ef712b17f3cdd01 system-lame.patch -9d55ced54a2c323c3e876db824ae2ba8 fix-pthread-sched.patch" +0d9dc1f09b6c150622bc59cdba86b89c 0001-FS-7969-resolve-Freeswitch-segfaults-due-to-pthread_.patch" sha256sums="46bb7e7f83dd616f268085c7e36fd45b48c3f02821dbea110211f0e10da16b09 freeswitch-1.4.20.tar.xz 816fb2d4baab09e2f51a7c1be75bc9e03ed09d4cf3c2cd03c183f433bb9b565f freeswitch-json-c-0.9.tar.gz 678c3860fd539402b5d1699b921239072af6acb4e72dc4720494112807cae411 freeswitch-flite-2.0.0-release.tar.bz2 @@ -233,11 +233,11 @@ b3a855acc96e0061a0c2b1162e8aff80b6b1a03849e3756786db2fcacfc9a9bd freeswitch-mpg ab437c92149b6fc88bc2fc8a228d6a5f8af574e2c90469a6dc4c753d13972c34 getlib.patch f83f9680d243eb254bf045571f971a6c5cf716367444cd48ed26d4c3367f4c41 modules.conf 846a29a361ef6eecd77876963b5c0133699c40fa8b34c68df42d5f8a1a1915b1 freeswitch.confd -9b5429cb74f4626c427f7ab198ad0487d8a20c0077e8612b845eca8318273baa freeswitch.initd +aa0d89221ffa47eba4a0e085f6041ee198476409dd15d1e90c5c357ba683f432 freeswitch.initd db0d3c252b5664ecb071bcf6868eff77c85dd7943a63fcfcac7e19db6a0ff61f libshout-disable-examples.patch be1009327de615f04956ba0b0f44183f31c263e380af8027f94b976a84bcb09a freeswitch-mod_shout-textrels.patch 11b107ca8632bb9c8fcb2aedfcfb421af24929aace4f56c34d4e701eb410e190 system-lame.patch -85f53fc313b9b72e7f7d2afb8720577d8ce4415b56a997d0bbab98986d04d452 fix-pthread-sched.patch" +1e3c67da8c17130d872213c718b8113f7cb08e67e166a91e2507facd8cd15b58 0001-FS-7969-resolve-Freeswitch-segfaults-due-to-pthread_.patch" sha512sums="f7f3209ed5c6de4b0c92edd772d12f7a62342289db142d05f7559b0053f9e4e17d65f1d7680abdbda1743a4b30764bc13941c24edb9541265d2c08f99cbe0a64 freeswitch-1.4.20.tar.xz 38b8729275bbfebaee783e703d19481f3d32b50cfdeb338644b8db2742573ea025702c789b5ce8d5067dcde23c5a16b46231eaadf0b9c5dbff392d410912c772 freeswitch-json-c-0.9.tar.gz e2b353721d0316fbd7948f90f9c9561d080eebd50e8dd0449a9c803ffbdb060a469385fadd63f535ade8d627cba37928d8e72ac61d5bcf98f73ca5ebb66549f8 freeswitch-flite-2.0.0-release.tar.bz2 @@ -247,8 +247,8 @@ d517d1d6a79dfd4819c42603faafc051c69270831f4894c01f6bd38e877eb008f8458534857641fd 4ceb48f64d2bc26a02cc0846276506241bfd30c156422b0a1d608fd172c099feb5c121a763652e9a45046dcdd0ba0eb71eab240e0c6ce2ad63ff781719e135a4 getlib.patch 6330e47cd3dcfdb4f5c99e91c9c725c7c8aa4f1691d83817d7600e510b5a586f3312bab84df3766448bbdab78cd1feebecf64b8280626b3f751f6e787f145e23 modules.conf a585f6411185a26206137a1ad97a06fd6c73e80c5439e9be45eabfa70e7a83120169ba882971fcd328436c8e0242cbd664170b80754ea2846021689baf1f1595 freeswitch.confd -d823ce7924f281b5808ffec0cd99569cd161b0749eca77dd076ea0dc86502e4d767c2fd2ff0d0c9c7ff67df3e077769268024a8e447a3ca19f77f28a2de775a4 freeswitch.initd +643d0a2e43f5d3bf3b99fcb6f6422302cb4b74a95eccf844eafb100b15aa9856b4ff41f112d6637255c2e9e2bec9fedc9a9215dfff214dfb83b52eae16b71dca freeswitch.initd 91a6d7c8456de65855930b371f568f0230c28422e667453aa48fababd185b47677c06ff0c79f94c2a02182439b012d48cb54548cbde3d12b8d0e1ffbb9b229cc libshout-disable-examples.patch 5f085254ca9f5dc196afd39fc55e083b1998e776d9de2428e5657d99077526c33c1fc13f12432598184ce63138447fed7c318c384b743681703f5682dc8e1e50 freeswitch-mod_shout-textrels.patch 398dd0f2665415ff40348dc94d26ec7008fb59ec033f9d2c64dc1aa01071021f83f47954e95efc58c4033f22bb6da159e83e3b0d36b99189d5e7535ed6ae70bd system-lame.patch -92a5c48874bf99e458939cb870165cd9983813f7742dfe60007d75f6d5f899d80f4d94f654fb8fd1039b67677702c3a972aaa64623d3c0fa5030248a8db0091e fix-pthread-sched.patch" +342abf9f41b7d957759228d5d81aceba1f0862871e29e55f7b46b45001e77e40bc577020fc0f3e693645f39c54a69a13d16ad17776bc49b1f0f05a244c98d5f8 0001-FS-7969-resolve-Freeswitch-segfaults-due-to-pthread_.patch" diff --git a/main/freeswitch/fix-pthread-sched.patch b/main/freeswitch/fix-pthread-sched.patch deleted file mode 100644 index ed12d1b526..0000000000 --- a/main/freeswitch/fix-pthread-sched.patch +++ /dev/null @@ -1,38 +0,0 @@ -Set sched priority via pthread_attr_* before thread is created. - -This fixes segfault when trying to modify scheduling priority if thread -exits before pthread_setschedparam() is called. - -diff --git a/libs/apr/threadproc/unix/thread.c b/libs/apr/threadproc/unix/thread.c -index 8859e79..a34e29f 100644 ---- a/libs/apr/threadproc/unix/thread.c -+++ b/libs/apr/threadproc/unix/thread.c -@@ -174,19 +174,16 @@ 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) { -+ struct sched_param param; -+ if (pthread_attr_getschedparam(&attr->attr, ¶m) == 0) { -+ param.sched_priority = attr->priority; -+ pthread_attr_setschedparam(&attr->attr, ¶m); -+ pthread_attr_setinheritsched(&attr->attr, PTHREAD_EXPLICIT_SCHED); -+ } -+ } - -+ if ((stat = pthread_create(&tt, temp, dummy_worker, (*new))) == 0) { - *(*new)->td = tt; - - return APR_SUCCESS; diff --git a/main/freeswitch/freeswitch.initd b/main/freeswitch/freeswitch.initd index 452a38bbe9..bbcb6f463a 100755 --- a/main/freeswitch/freeswitch.initd +++ b/main/freeswitch/freeswitch.initd @@ -52,7 +52,7 @@ stop() { ebegin "Stopping Freeswitch" start-stop-daemon --quiet --stop \ --pidfile $pidfile \ - --retry 10 \ + --retry 20 \ --exec /usr/bin/freeswitch eend $? } -- cgit v1.2.3