mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-09 03:18:30 +00:00
Dialplan functions: Fix some channel autoservice misuse.
* 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
This commit is contained in:
@@ -636,16 +636,16 @@ static int acf_curl_helper(struct ast_channel *chan, const char *cmd, char *info
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan) {
|
|
||||||
ast_autoservice_start(chan);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(curl = ast_threadstorage_get(&curl_instance, sizeof(*curl)))) {
|
if (!(curl = ast_threadstorage_get(&curl_instance, sizeof(*curl)))) {
|
||||||
ast_log(LOG_ERROR, "Cannot allocate curl structure\n");
|
ast_log(LOG_ERROR, "Cannot allocate curl structure\n");
|
||||||
ast_free(str);
|
ast_free(str);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chan) {
|
||||||
|
ast_autoservice_start(chan);
|
||||||
|
}
|
||||||
|
|
||||||
AST_LIST_LOCK(&global_curl_info);
|
AST_LIST_LOCK(&global_curl_info);
|
||||||
AST_LIST_TRAVERSE(&global_curl_info, cur, list) {
|
AST_LIST_TRAVERSE(&global_curl_info, cur, list) {
|
||||||
if (cur->key == CURLOPT_SPECIAL_HASHCOMPAT) {
|
if (cur->key == CURLOPT_SPECIAL_HASHCOMPAT) {
|
||||||
@@ -656,7 +656,11 @@ static int acf_curl_helper(struct ast_channel *chan, const char *cmd, char *info
|
|||||||
}
|
}
|
||||||
AST_LIST_UNLOCK(&global_curl_info);
|
AST_LIST_UNLOCK(&global_curl_info);
|
||||||
|
|
||||||
if (chan && (store = ast_channel_datastore_find(chan, &curl_info, NULL))) {
|
if (chan) {
|
||||||
|
ast_channel_lock(chan);
|
||||||
|
store = ast_channel_datastore_find(chan, &curl_info, NULL);
|
||||||
|
ast_channel_unlock(chan);
|
||||||
|
if (store) {
|
||||||
list = store->data;
|
list = store->data;
|
||||||
AST_LIST_LOCK(list);
|
AST_LIST_LOCK(list);
|
||||||
AST_LIST_TRAVERSE(list, cur, list) {
|
AST_LIST_TRAVERSE(list, cur, list) {
|
||||||
@@ -667,6 +671,7 @@ static int acf_curl_helper(struct ast_channel *chan, const char *cmd, char *info
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
curl_easy_setopt(*curl, CURLOPT_URL, args.url);
|
curl_easy_setopt(*curl, CURLOPT_URL, args.url);
|
||||||
curl_easy_setopt(*curl, CURLOPT_FILE, (void *) &str);
|
curl_easy_setopt(*curl, CURLOPT_FILE, (void *) &str);
|
||||||
|
|||||||
@@ -227,6 +227,9 @@ static int function_realtime_read(struct ast_channel *chan, const char *cmd, cha
|
|||||||
|
|
||||||
if (resultslen > len) {
|
if (resultslen > len) {
|
||||||
ast_log(LOG_WARNING, "Failed to fetch. Realtime data is too large: need %zu, have %zu.\n", 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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,6 +463,9 @@ static int function_realtime_readdestroy(struct ast_channel *chan, const char *c
|
|||||||
* someones data without giving him the chance to look
|
* someones data without giving him the chance to look
|
||||||
* at it. */
|
* at it. */
|
||||||
ast_log(LOG_WARNING, "Failed to fetch/destroy. Realtime data is too large: need %zu, have %zu.\n", resultslen, len);
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -942,10 +942,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);
|
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) {
|
if (pos > 128) {
|
||||||
pos = 128;
|
pos = 128;
|
||||||
}
|
}
|
||||||
@@ -966,9 +962,6 @@ int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int txt
|
|||||||
} else {
|
} else {
|
||||||
ast_copy_string(txt, context.txt, txtlen);
|
ast_copy_string(txt, context.txt, txtlen);
|
||||||
}
|
}
|
||||||
if (chan) {
|
|
||||||
ret |= ast_autoservice_stop(chan);
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user