diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-30 19:21:04 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-30 19:21:04 +0000 |
commit | 712c72b0df2fb7badefffb68c319f4a105ae9c71 (patch) | |
tree | 89d592fc9e276ed41a21062589ea44fedcf6d0d2 /apps/app_while.c | |
parent | 829d44846c2cbb8f568e5368c8e033daba211ae0 (diff) |
Lock around variables retrieved, and copy the values, if they stay persistent,
since another thread could remove them.
(closes issue #12541)
Reported by: snuffy
Patches:
bug_12156_apps.diff uploaded by snuffy (license 35)
Several additional changes by me
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@114904 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_while.c')
-rw-r--r-- | apps/app_while.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/apps/app_while.c b/apps/app_while.c index 1c61d966e..36dd17c5f 100644 --- a/apps/app_while.c +++ b/apps/app_while.c @@ -184,22 +184,19 @@ static int _while_exec(struct ast_channel *chan, void *data, int end) memset(my_name, 0, size); snprintf(my_name, size, "%s_%s_%d", chan->context, chan->exten, chan->priority); - if (ast_strlen_zero(label)) { - if (end) - label = used_index; - else if (!(label = pbx_builtin_getvar_helper(chan, my_name))) { - label = new_index; - pbx_builtin_setvar_helper(chan, my_name, label); - } - + ast_channel_lock(chan); + if (end) { + label = used_index; + } else if (!(label = pbx_builtin_getvar_helper(chan, my_name))) { + label = new_index; + pbx_builtin_setvar_helper(chan, my_name, label); } - snprintf(varname, VAR_SIZE, "%s_%s", prefix, label); - while_pri = pbx_builtin_getvar_helper(chan, varname); - if ((while_pri = pbx_builtin_getvar_helper(chan, varname)) && !end) { + while_pri = ast_strdupa(while_pri); snprintf(end_varname,VAR_SIZE,"END_%s",varname); } + ast_channel_unlock(chan); if ((!end && !pbx_checkcondition(condition)) || (end == 2)) { @@ -208,7 +205,8 @@ static int _while_exec(struct ast_channel *chan, void *data, int end) pbx_builtin_setvar_helper(chan, varname, NULL); pbx_builtin_setvar_helper(chan, my_name, NULL); snprintf(end_varname,VAR_SIZE,"END_%s",varname); - if ((goto_str=pbx_builtin_getvar_helper(chan, end_varname))) { + ast_channel_lock(chan); + if ((goto_str = pbx_builtin_getvar_helper(chan, end_varname))) { ast_parseable_goto(chan, goto_str); pbx_builtin_setvar_helper(chan, end_varname, NULL); } else { @@ -220,6 +218,7 @@ static int _while_exec(struct ast_channel *chan, void *data, int end) ast_log(LOG_WARNING, "Couldn't find matching EndWhile? (While at %s@%s priority %d)\n", chan->context, chan->exten, chan->priority); } } + ast_channel_unlock(chan); return res; } @@ -230,7 +229,7 @@ static int _while_exec(struct ast_channel *chan, void *data, int end) memset(goto_str, 0, size); snprintf(goto_str, size, "%s,%s,%d", chan->context, chan->exten, chan->priority); pbx_builtin_setvar_helper(chan, varname, goto_str); - } + } else if (end && while_pri) { /* END of loop */ |