CDR: Fix deadlock setting some CDR values.
[asterisk/asterisk.git] / funcs / func_channel.c
index eb3cedd..b72cb14 100644 (file)
@@ -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);