aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2009-06-18 15:40:15 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2009-06-18 15:40:15 +0000
commite7fcf24d333393e808291fd319785a064de51b72 (patch)
tree1db189014f6bd34a30a209fa4bdfc3b1446fe1f0 /res
parent20aedf207e9249fb76647fcc832f73e947754a07 (diff)
Merged revisions 201610 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r201610 | russell | 2009-06-18 10:27:10 -0500 (Thu, 18 Jun 2009) | 36 lines Merged revisions 201600 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r201600 | russell | 2009-06-18 10:24:31 -0500 (Thu, 18 Jun 2009) | 29 lines Fix memory corruption and leakage related reloads of non files mode MoH classes. For Music on Hold classes that are not files mode, meaning that we are executing an application that will feed us audio data, we use a thread to monitor the external application and read audio from it. This thread also makes use of the MoH class object. In the MoH class destructor, we used pthread_cancel() to ask the thread to exit. Unfortunately, the code did not wait to ensure that the thread actually went away. What needed to be done is a pthread_join() to ensure that the thread fully cleans up before we proceed. By adding this one line, we resolve two significant problems: 1) Since the thread was never joined, it never fully goes away. So, on every reload of non-files mode MoH, an unused thread was sticking around. 2) There was a race condition here where the application monitoring thread could still try to access the MoH class, even though the thread executing the MoH reload has already destroyed it. (issue #15109) Reported by: jvandal (issue #15123) Reported by: axisinternet (issue #15195) Reported by: amorsen (issue AST-208) ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@201614 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r--res/res_musiconhold.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index c1ab05dac..bb2010323 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -1395,9 +1395,10 @@ static void moh_class_destructor(void *obj)
while ((member = AST_LIST_REMOVE_HEAD(&class->members, list))) {
free(member);
}
-
+
if (class->thread) {
pthread_cancel(class->thread);
+ pthread_join(class->thread, NULL);
class->thread = AST_PTHREADT_NULL;
}