From d9392089cfe08ad092367b2dca9054f413ccb529 Mon Sep 17 00:00:00 2001 From: Paul Sadauskas Date: Sun, 14 Jun 2009 19:52:18 -0600 Subject: [PATCH] http plugin: Initialze curl every time, to we don't clobber things --- src/http.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/http.c b/src/http.c index 2cce5803..d58eda47 100644 --- a/src/http.c +++ b/src/http.c @@ -44,25 +44,16 @@ char *user; char *pass; char *credentials; -CURL *curl; -char curl_errbuf[CURL_ERROR_SIZE]; -struct curl_slist *headers=NULL; - -static int http_init(void) +static int http_init_curl(CURL *curl, char curl_errbuf[]) { - - curl = curl_easy_init (); - if (curl == NULL) - { - ERROR ("curl plugin: curl_easy_init failed."); - return (-1); - } + struct curl_slist *headers=NULL; curl_easy_setopt (curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION); - headers = curl_slist_append(headers, "Accept: application/vnd.absperf.ssbe+json"); - headers = curl_slist_append(headers, "Content-Type: text/csv"); + headers = curl_slist_append(headers, "Accept: text/csv"); + headers = curl_slist_append(headers, "Content-Type: text/csv"); curl_easy_setopt (curl, CURLOPT_HTTPHEADER, headers); + curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, curl_errbuf); curl_easy_setopt (curl, CURLOPT_URL, location); @@ -90,6 +81,11 @@ static int http_init(void) return (0); } +static int http_init(void) +{ + return (0); +} + static int value_list_to_string (char *buffer, int buffer_len, const data_set_t *ds, const value_list_t *vl, int index) { @@ -287,6 +283,9 @@ static int http_config (const char *key, const char *value) static int http_write (const data_set_t *ds, const value_list_t *vl, user_data_t __attribute__((unused)) *user_data) { + CURL *curl; + char curl_errbuf[CURL_ERROR_SIZE]; + char metric_name[512]; int metric_prefix_len; char value[512]; @@ -303,6 +302,15 @@ static int http_write (const data_set_t *ds, const value_list_t *vl, return -1; } + curl = curl_easy_init (); + if (curl == NULL) + { + ERROR ("curl plugin: curl_easy_init failed."); + return (-1); + } + + http_init_curl(curl, curl_errbuf); + metric_prefix_len = value_list_to_metric_name (metric_name, sizeof (metric_name), ds, vl); -- 2.11.0