]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
update to use trunk's version of the threadstorage API
authorKevin P. Fleming <kpfleming@digium.com>
Sat, 16 Dec 2006 21:24:08 +0000 (21:24 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Sat, 16 Dec 2006 21:24:08 +0000 (21:24 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48526 65c4cc65-6c06-0410-ace0-fbb531ad65f3

funcs/func_curl.c

index 08e786eaff23b3db6aa05190b0c4e27b8259fd74..bd53e0a45b1aef0491273d7ecf38eba1fe2e6020 100644 (file)
@@ -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);