[asterisk-commits] jrose: trunk r391828 - in /trunk: ./ apps/app_mixmonitor.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jun 14 11:32:45 CDT 2013
Author: jrose
Date: Fri Jun 14 11:32:43 2013
New Revision: 391828
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=391828
Log:
app_mixmonitor: Fix crashes caused by unloading app_mixmonitor
Unloading app_mixmonitor while active mixmonitors were running would
cause a segfault. This patch fixes that by making it impossible to
unload app_mixmonitor while mixmonitors are active.
Review: https://reviewboard.asterisk.org/r/2624/
........
Merged revisions 391778 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 391794 from http://svn.asterisk.org/svn/asterisk/branches/11
Modified:
trunk/ (props changed)
trunk/apps/app_mixmonitor.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.
Modified: trunk/apps/app_mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_mixmonitor.c?view=diff&rev=391828&r1=391827&r2=391828
==============================================================================
--- trunk/apps/app_mixmonitor.c (original)
+++ trunk/apps/app_mixmonitor.c Fri Jun 14 11:32:43 2013
@@ -744,6 +744,8 @@
}
mixmonitor_free(mixmonitor);
+
+ ast_module_unref(ast_module_info->self);
return NULL;
}
@@ -783,7 +785,7 @@
return 0;
}
-static void launch_monitor_thread(struct ast_channel *chan, const char *filename,
+static int launch_monitor_thread(struct ast_channel *chan, const char *filename,
unsigned int flags, int readvol, int writevol,
const char *post_process, const char *filename_write,
char *filename_read, const char *uid_channel_var,
@@ -810,33 +812,33 @@
/* Pre-allocate mixmonitor structure and spy */
if (!(mixmonitor = ast_calloc(1, sizeof(*mixmonitor)))) {
- return;
+ return -1;
}
/* Now that the struct has been calloced, go ahead and initialize the string fields. */
if (ast_string_field_init(mixmonitor, 512)) {
mixmonitor_free(mixmonitor);
- return;
+ return -1;
}
/* Setup the actual spy before creating our thread */
if (ast_audiohook_init(&mixmonitor->audiohook, AST_AUDIOHOOK_TYPE_SPY, mixmonitor_spy_type, 0)) {
mixmonitor_free(mixmonitor);
- return;
+ return -1;
}
/* Copy over flags and channel name */
mixmonitor->flags = flags;
if (!(mixmonitor->autochan = ast_autochan_setup(chan))) {
mixmonitor_free(mixmonitor);
- return;
+ return -1;
}
if (setup_mixmonitor_ds(mixmonitor, chan, &datastore_id)) {
ast_autochan_destroy(mixmonitor->autochan);
mixmonitor_free(mixmonitor);
ast_free(datastore_id);
- return;
+ return -1;
}
if (!ast_strlen_zero(uid_channel_var)) {
@@ -905,13 +907,13 @@
mixmonitor_spy_type, ast_channel_name(chan));
ast_audiohook_destroy(&mixmonitor->audiohook);
mixmonitor_free(mixmonitor);
- return;
+ return -1;
}
/* reference be released at mixmonitor destruction */
mixmonitor->callid = ast_read_threadstorage_callid();
- ast_pthread_create_detached_background(&thread, NULL, mixmonitor_thread, mixmonitor);
+ return ast_pthread_create_detached_background(&thread, NULL, mixmonitor_thread, mixmonitor);
}
/* a note on filename_parse: creates directory structure and assigns absolute path from relative paths for filenames */
@@ -1032,7 +1034,10 @@
}
pbx_builtin_setvar_helper(chan, "MIXMONITOR_FILENAME", args.filename);
- launch_monitor_thread(chan,
+
+ /* If launch_monitor_thread works, the module reference must not be released until it is finished. */
+ ast_module_ref(ast_module_info->self);
+ if (launch_monitor_thread(chan,
args.filename,
flags.flags,
readvol,
@@ -1041,7 +1046,9 @@
filename_write,
filename_read,
uid_channel_var,
- recipients);
+ recipients)) {
+ ast_module_unref(ast_module_info->self);
+ }
return 0;
}
More information about the asterisk-commits
mailing list