func_curl.c: Ensure channel is locked when manipulating datastores.
This commit is contained in:
parent
9e44d0e2d2
commit
028ebdcc10
|
@ -341,16 +341,19 @@ static int acf_curlopt_write(struct ast_channel *chan, const char *cmd, char *na
|
||||||
enum optiontype ot;
|
enum optiontype ot;
|
||||||
|
|
||||||
if (chan) {
|
if (chan) {
|
||||||
|
ast_channel_lock(chan);
|
||||||
if (!(store = ast_channel_datastore_find(chan, &curl_info, NULL))) {
|
if (!(store = ast_channel_datastore_find(chan, &curl_info, NULL))) {
|
||||||
/* Create a new datastore */
|
/* Create a new datastore */
|
||||||
if (!(store = ast_datastore_alloc(&curl_info, NULL))) {
|
if (!(store = ast_datastore_alloc(&curl_info, NULL))) {
|
||||||
ast_log(LOG_ERROR, "Unable to allocate new datastore. Cannot set any CURL options\n");
|
ast_log(LOG_ERROR, "Unable to allocate new datastore. Cannot set any CURL options\n");
|
||||||
|
ast_channel_unlock(chan);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(list = ast_calloc(1, sizeof(*list)))) {
|
if (!(list = ast_calloc(1, sizeof(*list)))) {
|
||||||
ast_log(LOG_ERROR, "Unable to allocate list head. Cannot set any CURL options\n");
|
ast_log(LOG_ERROR, "Unable to allocate list head. Cannot set any CURL options\n");
|
||||||
ast_datastore_free(store);
|
ast_datastore_free(store);
|
||||||
|
ast_channel_unlock(chan);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,6 +363,7 @@ static int acf_curlopt_write(struct ast_channel *chan, const char *cmd, char *na
|
||||||
} else {
|
} else {
|
||||||
list = store->data;
|
list = store->data;
|
||||||
}
|
}
|
||||||
|
ast_channel_unlock(chan);
|
||||||
} else {
|
} else {
|
||||||
/* Populate the global structure */
|
/* Populate the global structure */
|
||||||
list = &global_curl_info;
|
list = &global_curl_info;
|
||||||
|
@ -472,10 +476,18 @@ static int acf_curlopt_helper(struct ast_channel *chan, const char *cmd, char *d
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan && (store = ast_channel_datastore_find(chan, &curl_info, NULL))) {
|
if (chan) {
|
||||||
|
/* If we have a channel, we want to read the options set there before
|
||||||
|
falling back to the global settings */
|
||||||
|
ast_channel_lock(chan);
|
||||||
|
store = ast_channel_datastore_find(chan, &curl_info, NULL);
|
||||||
|
ast_channel_unlock(chan);
|
||||||
|
|
||||||
|
if (store) {
|
||||||
list[0] = store->data;
|
list[0] = store->data;
|
||||||
list[1] = &global_curl_info;
|
list[1] = &global_curl_info;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
if (!list[i]) {
|
if (!list[i]) {
|
||||||
|
|
Loading…
Reference in New Issue