diff -rupN asterisk-1.8.5.0.orig/funcs/func_curl.c asterisk-1.8.5.0.new/funcs/func_curl.c --- asterisk-1.8.5.0.orig/funcs/func_curl.c 2011-05-02 15:09:55.000000000 -0400 +++ asterisk-1.8.5.0.new/funcs/func_curl.c 2011-10-14 14:19:37.000000000 -0400 @@ -63,24 +63,24 @@ static struct ast_datastore_info curl_in }; struct curl_settings { - AST_LIST_ENTRY(curl_settings) list; + AST_RWLIST_ENTRY(curl_settings) list; CURLoption key; void *value; }; -AST_LIST_HEAD_STATIC(global_curl_info, curl_settings); +AST_RWLIST_HEAD_STATIC(global_curl_info, curl_settings); static void curlds_free(void *data) { - AST_LIST_HEAD(global_curl_info, curl_settings) *list = data; + AST_RWLIST_HEAD(global_curl_info, curl_settings) *list = data; struct curl_settings *setting; if (!list) { return; } - while ((setting = AST_LIST_REMOVE_HEAD(list, list))) { + while ((setting = AST_RWLIST_REMOVE_HEAD(list, list))) { free(setting); } - AST_LIST_HEAD_DESTROY(list); + AST_RWLIST_HEAD_DESTROY(list); } enum optiontype { @@ -182,7 +182,7 @@ static int acf_curlopt_write(struct ast_ } store->data = list; - AST_LIST_HEAD_INIT(list); + AST_RWLIST_HEAD_INIT(list); ast_channel_datastore_add(chan, store); } else { list = store->data; @@ -261,7 +261,7 @@ yuck: } /* Remove any existing entry */ - AST_LIST_LOCK(list); + AST_RWLIST_WRLOCK(list); AST_LIST_TRAVERSE_SAFE_BEGIN(list, cur, list) { if (cur->key == new->key) { AST_LIST_REMOVE_CURRENT(list); @@ -274,7 +274,7 @@ yuck: /* Insert new entry */ ast_debug(1, "Inserting entry %p with key %d and value %p\n", new, new->key, new->value); AST_LIST_INSERT_TAIL(list, new, list); - AST_LIST_UNLOCK(list); + AST_RWLIST_UNLOCK(list); return 0; } @@ -302,7 +302,7 @@ static int acf_curlopt_helper(struct ast if (!list[i]) { break; } - AST_LIST_LOCK(list[i]); + AST_RWLIST_RDLOCK(list[i]); AST_LIST_TRAVERSE(list[i], cur, list) { if (cur->key == key) { if (ot == OT_BOOLEAN || ot == OT_INTEGER) { @@ -383,7 +383,7 @@ static int acf_curlopt_helper(struct ast break; } } - AST_LIST_UNLOCK(list[i]); + AST_RWLIST_UNLOCK(list[i]); if (cur) { break; } @@ -456,7 +456,7 @@ static int acf_curl_helper(struct ast_ch struct curl_settings *cur; struct ast_datastore *store = NULL; int hashcompat = 0; - AST_LIST_HEAD(global_curl_info, curl_settings) *list = NULL; + AST_RWLIST_HEAD(global_curl_info, curl_settings) *list = NULL; if (buf) { *buf = '\0'; @@ -483,7 +483,7 @@ static int acf_curl_helper(struct ast_ch return -1; } - AST_LIST_LOCK(&global_curl_info); + AST_RWLIST_RDLOCK(&global_curl_info); AST_LIST_TRAVERSE(&global_curl_info, cur, list) { if (cur->key == CURLOPT_SPECIAL_HASHCOMPAT) { hashcompat = (cur->value != NULL) ? 1 : 0; @@ -494,7 +494,7 @@ static int acf_curl_helper(struct ast_ch if (chan && (store = ast_channel_datastore_find(chan, &curl_info, NULL))) { list = store->data; - AST_LIST_LOCK(list); + AST_RWLIST_RDLOCK(list); AST_LIST_TRAVERSE(list, cur, list) { if (cur->key == CURLOPT_SPECIAL_HASHCOMPAT) { hashcompat = (cur->value != NULL) ? 1 : 0; @@ -502,6 +502,7 @@ static int acf_curl_helper(struct ast_ch curl_easy_setopt(*curl, cur->key, cur->value); } } + AST_RWLIST_UNLOCK(list); } curl_easy_setopt(*curl, CURLOPT_URL, args.url); @@ -511,14 +512,10 @@ static int acf_curl_helper(struct ast_ch curl_easy_setopt(*curl, CURLOPT_POST, 1); curl_easy_setopt(*curl, CURLOPT_POSTFIELDS, args.postdata); } + AST_RWLIST_UNLOCK(&global_curl_info); curl_easy_perform(*curl); - if (store) { - AST_LIST_UNLOCK(list); - } - AST_LIST_UNLOCK(&global_curl_info); - if (args.postdata) { curl_easy_setopt(*curl, CURLOPT_POST, 0); }