From a2ec1d322cd3bfdc9b1e16e114518eb19815f91e Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Sat, 16 Dec 2006 21:24:08 +0000 Subject: [PATCH] update to use trunk's version of the threadstorage API git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48526 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- funcs/func_curl.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/funcs/func_curl.c b/funcs/func_curl.c index 08e786eaff..bd53e0a45b 100644 --- a/funcs/func_curl.c +++ b/funcs/func_curl.c @@ -84,6 +84,21 @@ static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *da static const char *global_useragent = "asterisk-libcurl-agent/1.0"; +static int curl_instance_init(void *data) +{ + CURL **curl = data; + + if (!(*curl = curl_easy_init())) + return -1; + + curl_easy_setopt(*curl, CURLOPT_NOSIGNAL, 1); + curl_easy_setopt(*curl, CURLOPT_TIMEOUT, 180); + curl_easy_setopt(*curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); + curl_easy_setopt(*curl, CURLOPT_USERAGENT, global_useragent); + + return 0; +} + static void curl_instance_cleanup(void *data) { CURL **curl = data; @@ -100,15 +115,6 @@ static int curl_internal(struct MemoryStruct *chunk, char *url, char *post) if (!(curl = ast_threadstorage_get(&curl_instance, sizeof(*curl)))) return -1; - if (!*curl) { - if (!(*curl = curl_easy_init())) - return -1; - curl_easy_setopt(*curl, CURLOPT_NOSIGNAL, 1); - curl_easy_setopt(*curl, CURLOPT_TIMEOUT, 180); - curl_easy_setopt(*curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); - curl_easy_setopt(*curl, CURLOPT_USERAGENT, global_useragent); - } - curl_easy_setopt(*curl, CURLOPT_URL, url); curl_easy_setopt(*curl, CURLOPT_WRITEDATA, (void *) chunk); -- 2.47.2