]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Dialplan functions: Fix some channel autoservice misuse.
authorRichard Mudgett <rmudgett@digium.com>
Mon, 18 Jun 2018 21:07:47 +0000 (16:07 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 19 Jun 2018 16:54:47 +0000 (11:54 -0500)
* Fix off nominal paths leaving the channel in autoservice.
* Remove unnecessary start/stop channel autoservice.
* Fix channel locking around a channel datastore search.

Change-Id: I7ff2e42388064fe3149034ecae57604040b8b540

funcs/func_curl.c
funcs/func_realtime.c
main/enum.c

index ebb3dce23cb4fefe8ca1aa5d59651b53be833af0..caf3c9274f871ecb21f92c7d0c631596cfa9b5a8 100644 (file)
@@ -672,14 +672,19 @@ static int acf_curl_helper(struct ast_channel *chan, struct curl_args *args)
        }
        AST_LIST_UNLOCK(&global_curl_info);
 
-       if (chan && (store = ast_channel_datastore_find(chan, &curl_info, NULL))) {
-               list = store->data;
-               AST_LIST_LOCK(list);
-               AST_LIST_TRAVERSE(list, cur, list) {
-                       if (cur->key == CURLOPT_SPECIAL_HASHCOMPAT) {
-                               hashcompat = (long) cur->value;
-                       } else {
-                               curl_easy_setopt(*curl, cur->key, cur->value);
+       if (chan) {
+               ast_channel_lock(chan);
+               store = ast_channel_datastore_find(chan, &curl_info, NULL);
+               ast_channel_unlock(chan);
+               if (store) {
+                       list = store->data;
+                       AST_LIST_LOCK(list);
+                       AST_LIST_TRAVERSE(list, cur, list) {
+                               if (cur->key == CURLOPT_SPECIAL_HASHCOMPAT) {
+                                       hashcompat = (long) cur->value;
+                               } else {
+                                       curl_easy_setopt(*curl, cur->key, cur->value);
+                               }
                        }
                }
        }
index e0ba4a5a18ead90019942924b3014261cdbbc02f..ef7fe2a5efa73b0fe6590d9c3f51353e1e524f37 100644 (file)
@@ -225,6 +225,9 @@ static int function_realtime_read(struct ast_channel *chan, const char *cmd, cha
 
        if (resultslen > len) {
                ast_log(LOG_WARNING, "Failed to fetch. Realtime data is too large: need %zu, have %zu.\n", resultslen, len);
+               if (chan) {
+                       ast_autoservice_stop(chan);
+               }
                return -1;
        }
 
@@ -458,6 +461,9 @@ static int function_realtime_readdestroy(struct ast_channel *chan, const char *c
                         * someones data without giving him the chance to look
                         * at it. */
                        ast_log(LOG_WARNING, "Failed to fetch/destroy. Realtime data is too large: need %zu, have %zu.\n", resultslen, len);
+                       if (chan) {
+                               ast_autoservice_stop(chan);
+                       }
                        return -1;
                }
 
index 5c217c43ca2356cbe4e76b3fc1d71ebbff150cbd..008cc883cafca009fc00a584cf072c4d41cc4620 100644 (file)
@@ -940,10 +940,6 @@ int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int txt
 
        ast_debug(4, "ast_get_txt: Number = '%s', suffix = '%s'\n", number, suffix);
 
-       if (chan && ast_autoservice_start(chan) < 0) {
-               return -1;
-       }
-
        if (pos > 128) {
                pos = 128;
        }
@@ -964,9 +960,6 @@ int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int txt
        } else {
                ast_copy_string(txt, context.txt, txtlen);
        }
-       if (chan) {
-               ret |= ast_autoservice_stop(chan);
-       }
        return ret;
 }