[svn-commits] jrose: branch 1.8 r391778 - /branches/1.8/apps/app_mixmonitor.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Jun 14 11:14:56 CDT 2013
Author: jrose
Date: Fri Jun 14 11:14:48 2013
New Revision: 391778
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=391778
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/
Modified:
branches/1.8/apps/app_mixmonitor.c
Modified: branches/1.8/apps/app_mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/apps/app_mixmonitor.c?view=diff&rev=391778&r1=391777&r2=391778
==============================================================================
--- branches/1.8/apps/app_mixmonitor.c (original)
+++ branches/1.8/apps/app_mixmonitor.c Fri Jun 14 11:14:48 2013
@@ -381,6 +381,8 @@
ast_verb(2, "End MixMonitor Recording %s\n", mixmonitor->name);
mixmonitor_free(mixmonitor);
+
+ ast_module_unref(ast_module_info->self);
return NULL;
}
@@ -414,7 +416,7 @@
return 0;
}
-static void launch_monitor_thread(struct ast_channel *chan, const char *filename, unsigned int flags,
+static int launch_monitor_thread(struct ast_channel *chan, const char *filename, unsigned int flags,
int readvol, int writevol, const char *post_process)
{
pthread_t thread;
@@ -442,26 +444,26 @@
/* Pre-allocate mixmonitor structure and spy */
if (!(mixmonitor = ast_calloc(1, len))) {
- return;
+ return -1;
}
/* Setup the actual spy before creating our thread */
if (ast_audiohook_init(&mixmonitor->audiohook, AST_AUDIOHOOK_TYPE_SPY, mixmonitor_spy_type)) {
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)) {
ast_autochan_destroy(mixmonitor->autochan);
mixmonitor_free(mixmonitor);
- return;
+ return -1;
}
mixmonitor->name = (char *) mixmonitor + sizeof(*mixmonitor);
strcpy(mixmonitor->name, chan->name);
@@ -485,10 +487,10 @@
mixmonitor_spy_type, chan->name);
ast_audiohook_destroy(&mixmonitor->audiohook);
mixmonitor_free(mixmonitor);
- return;
- }
-
- ast_pthread_create_detached_background(&thread, NULL, mixmonitor_thread, mixmonitor);
+ return -1;
+ }
+
+ return ast_pthread_create_detached_background(&thread, NULL, mixmonitor_thread, mixmonitor);
}
static int mixmonitor_exec(struct ast_channel *chan, const char *data)
@@ -567,7 +569,12 @@
ast_mkdir(tmp, 0777);
pbx_builtin_setvar_helper(chan, "MIXMONITOR_FILENAME", args.filename);
- launch_monitor_thread(chan, args.filename, flags.flags, readvol, writevol, args.post_process);
+
+ /* 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, writevol, args.post_process)) {
+ ast_module_unref(ast_module_info->self);
+ }
return 0;
}
More information about the svn-commits
mailing list