summaryrefslogtreecommitdiff
path: root/funcs/func_channel.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2017-12-05 18:04:47 -0600
committerRichard Mudgett <rmudgett@digium.com>2017-12-06 15:59:47 -0600
commitcf741d5de360a0df079c41867f934dcd8d64345b (patch)
tree859683b11564962a898cffe2c28e2f8d582fdb37 /funcs/func_channel.c
parentf28fdb46f152e6ddf632bdfcd1750d8402697d20 (diff)
CDR: Fix deadlock setting some CDR values.
Setting channel variables with the AMI Originate action caused a deadlock when you set CDR(amaflags) or CDR(accountcode). This path has the channel locked when the CDR function is called. The CDR function then synchronously passes the job to a stasis thread. The stasis handling function then attempts to lock the channel. Deadlock results. * Avoid deadlock by making the CDR function handle setting amaflags and accountcode directly on the channel rather than passing it off to the CDR processing code under a stasis thread to do it. * Made the CHANNEL function and the CDR function process amaflags the same way. * Fixed referencing the wrong message type in cdr_prop_write(). ASTERISK-27460 Change-Id: I5eacb47586bc0b8f8ff76a19bd92d1dc38b75e8f
Diffstat (limited to 'funcs/func_channel.c')
-rw-r--r--funcs/func_channel.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/funcs/func_channel.c b/funcs/func_channel.c
index eb3ceddb4..b72cb141e 100644
--- a/funcs/func_channel.c
+++ b/funcs/func_channel.c
@@ -495,18 +495,17 @@ static int func_channel_write_real(struct ast_channel *chan, const char *functio
ast_bridge_set_after_go_on(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), value);
}
} else if (!strcasecmp(data, "amaflags")) {
- ast_channel_lock(chan);
+ int amaflags;
+
if (isdigit(*value)) {
- int amaflags;
- sscanf(value, "%30d", &amaflags);
- ast_channel_amaflags_set(chan, amaflags);
- } else if (!strcasecmp(value,"OMIT")){
- ast_channel_amaflags_set(chan, 1);
- } else if (!strcasecmp(value,"BILLING")){
- ast_channel_amaflags_set(chan, 2);
- } else if (!strcasecmp(value,"DOCUMENTATION")){
- ast_channel_amaflags_set(chan, 3);
+ if (sscanf(value, "%30d", &amaflags) != 1) {
+ amaflags = AST_AMA_NONE;
+ }
+ } else {
+ amaflags = ast_channel_string2amaflag(value);
}
+ ast_channel_lock(chan);
+ ast_channel_amaflags_set(chan, amaflags);
ast_channel_unlock(chan);
} else if (!strcasecmp(data, "peeraccount"))
locked_string_field_set(chan, peeraccount, value);