mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
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
This commit is contained in:
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user