diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-12-16 21:24:08 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-12-16 21:24:08 +0000 |
commit | ad0e0a29d46f5097f7f55cec40a8e53e27fe6c2a (patch) | |
tree | 94e3bb3da1c75144c862956963a0b87bb341a9be /funcs | |
parent | ca962eb0c070a467ced531839145c0bdff48cbae (diff) |
update to use trunk's version of the threadstorage API
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48526 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r-- | funcs/func_curl.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/funcs/func_curl.c b/funcs/func_curl.c index 08e786eaf..bd53e0a45 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); |