[svn-commits] russell: branch russell/chan_refcount r89944 - /team/russell/chan_refcount/apps/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Nov 27 18:43:36 CST 2007
Author: russell
Date: Tue Nov 27 18:43:35 2007
New Revision: 89944
URL: http://svn.digium.com/view/asterisk?view=rev&rev=89944
Log:
minimize the time the channel lock is held, and add a missing unref
Modified:
team/russell/chan_refcount/apps/app_mixmonitor.c
Modified: team/russell/chan_refcount/apps/app_mixmonitor.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_mixmonitor.c?view=diff&rev=89944&r1=89943&r2=89944
==============================================================================
--- team/russell/chan_refcount/apps/app_mixmonitor.c (original)
+++ team/russell/chan_refcount/apps/app_mixmonitor.c Tue Nov 27 18:43:35 2007
@@ -213,8 +213,13 @@
struct mixmonitor *mixmonitor;
char postprocess2[1024] = "";
size_t len;
-
- len = sizeof(*mixmonitor) + strlen(chan->name) + strlen(filename) + 2;
+ const char *chan_name;
+
+ ast_channel_lock(chan);
+ chan_name = ast_strdupa(chan->name);
+ ast_channel_unlock(chan);
+
+ len = sizeof(*mixmonitor) + strlen(chan_name) + strlen(filename) + 2;
postprocess2[0] = 0;
/* If a post process system command is given attach it to the structure */
@@ -241,13 +246,13 @@
mixmonitor->flags = flags;
mixmonitor->chan = chan;
mixmonitor->name = (char *) mixmonitor + sizeof(*mixmonitor);
- strcpy(mixmonitor->name, chan->name);
+ strcpy(mixmonitor->name, chan_name);
if (!ast_strlen_zero(postprocess2)) {
mixmonitor->post_process = mixmonitor->name + strlen(mixmonitor->name) + strlen(filename) + 2;
strcpy(mixmonitor->post_process, postprocess2);
}
- mixmonitor->filename = (char *) mixmonitor + sizeof(*mixmonitor) + strlen(chan->name) + 1;
+ mixmonitor->filename = (char *) mixmonitor + sizeof(*mixmonitor) + strlen(chan_name) + 1;
strcpy(mixmonitor->filename, filename);
/* Setup the actual spy before creating our thread */
@@ -265,7 +270,7 @@
if (startmon(chan, &mixmonitor->audiohook)) {
ast_log(LOG_WARNING, "Unable to add '%s' spy to channel '%s'\n",
- mixmonitor_spy_type, chan->name);
+ mixmonitor_spy_type, chan_name);
ast_audiohook_destroy(&mixmonitor->audiohook);
ast_free(mixmonitor);
return;
@@ -350,10 +355,8 @@
*slash = '\0';
ast_mkdir(tmp, 0777);
- ast_channel_lock(chan);
pbx_builtin_setvar_helper(chan, "MIXMONITOR_FILENAME", args.filename);
launch_monitor_thread(chan, args.filename, flags.flags, readvol, writevol, args.post_process);
- ast_channel_unlock(chan);
return 0;
}
@@ -393,6 +396,8 @@
else
ast_audiohook_detach_source(chan, mixmonitor_spy_type);
+ ast_channel_unref(chan);
+
return CLI_SUCCESS;
}
More information about the svn-commits
mailing list