<p>Richard Mudgett has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/9206">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Dialplan functions: Fix some channel autoservice misuse.<br><br>* Fix off nominal paths leaving the channel in autoservice.<br>* Remove unnecessary start/stop channel autoservice.<br>* Fix channel locking around a channel datastore search.<br><br>Change-Id: I7ff2e42388064fe3149034ecae57604040b8b540<br>---<br>M funcs/func_curl.c<br>M funcs/func_realtime.c<br>M main/enum.c<br>3 files changed, 23 insertions(+), 19 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/06/9206/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/funcs/func_curl.c b/funcs/func_curl.c<br>index b1bb759..89a4688 100644<br>--- a/funcs/func_curl.c<br>+++ b/funcs/func_curl.c<br>@@ -636,14 +636,14 @@<br> return -1;<br> }<br> <br>- if (chan) {<br>- ast_autoservice_start(chan);<br>- }<br>-<br> if (!(curl = ast_threadstorage_get(&curl_instance, sizeof(*curl)))) {<br> ast_log(LOG_ERROR, "Cannot allocate curl structure\n");<br> ast_free(str);<br> return -1;<br>+ }<br>+<br>+ if (chan) {<br>+ ast_autoservice_start(chan);<br> }<br> <br> AST_LIST_LOCK(&global_curl_info);<br>@@ -656,14 +656,19 @@<br> }<br> AST_LIST_UNLOCK(&global_curl_info);<br> <br>- if (chan && (store = ast_channel_datastore_find(chan, &curl_info, NULL))) {<br>- list = store->data;<br>- AST_LIST_LOCK(list);<br>- AST_LIST_TRAVERSE(list, cur, list) {<br>- if (cur->key == CURLOPT_SPECIAL_HASHCOMPAT) {<br>- hashcompat = (long) cur->value;<br>- } else {<br>- curl_easy_setopt(*curl, cur->key, cur->value);<br>+ if (chan) {<br>+ ast_channel_lock(chan);<br>+ store = ast_channel_datastore_find(chan, &curl_info, NULL);<br>+ ast_channel_unlock(chan);<br>+ if (store) {<br>+ list = store->data;<br>+ AST_LIST_LOCK(list);<br>+ AST_LIST_TRAVERSE(list, cur, list) {<br>+ if (cur->key == CURLOPT_SPECIAL_HASHCOMPAT) {<br>+ hashcompat = (long) cur->value;<br>+ } else {<br>+ curl_easy_setopt(*curl, cur->key, cur->value);<br>+ }<br> }<br> }<br> }<br>diff --git a/funcs/func_realtime.c b/funcs/func_realtime.c<br>index a870ab4..2fc4df8 100644<br>--- a/funcs/func_realtime.c<br>+++ b/funcs/func_realtime.c<br>@@ -227,6 +227,9 @@<br> <br> if (resultslen > len) {<br> ast_log(LOG_WARNING, "Failed to fetch. Realtime data is too large: need %zu, have %zu.\n", resultslen, len);<br>+ if (chan) {<br>+ ast_autoservice_stop(chan);<br>+ }<br> return -1;<br> }<br> <br>@@ -460,6 +463,9 @@<br> * someones data without giving him the chance to look<br> * at it. */<br> ast_log(LOG_WARNING, "Failed to fetch/destroy. Realtime data is too large: need %zu, have %zu.\n", resultslen, len);<br>+ if (chan) {<br>+ ast_autoservice_stop(chan);<br>+ }<br> return -1;<br> }<br> <br>diff --git a/main/enum.c b/main/enum.c<br>index bae1299..e003f07 100644<br>--- a/main/enum.c<br>+++ b/main/enum.c<br>@@ -942,10 +942,6 @@<br> <br> ast_debug(4, "ast_get_txt: Number = '%s', suffix = '%s'\n", number, suffix);<br> <br>- if (chan && ast_autoservice_start(chan) < 0) {<br>- return -1;<br>- }<br>-<br> if (pos > 128) {<br> pos = 128;<br> }<br>@@ -965,9 +961,6 @@<br> ret = 0;<br> } else {<br> ast_copy_string(txt, context.txt, txtlen);<br>- }<br>- if (chan) {<br>- ret |= ast_autoservice_stop(chan);<br> }<br> return ret;<br> }<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9206">change 9206</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/9206"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I7ff2e42388064fe3149034ecae57604040b8b540 </div>
<div style="display:none"> Gerrit-Change-Number: 9206 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>