Code

Merge branch 'collectd-5.4' into collectd-5.5
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Sun, 20 Mar 2016 11:04:20 +0000 (12:04 +0100)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Sun, 20 Mar 2016 11:04:20 +0000 (12:04 +0100)
1  2 
src/write_http.c

index ed596bbf56b9e9ee88becd425126951a4591fb91,c2968290055013ada258b019461a7d454130f36a..06a82fec5c6ff9fd7e700c4c74aa00649522c4c6
@@@ -68,10 -56,10 +68,11 @@@ struct wh_callback_
          int format;
  
          CURL *curl;
+         struct curl_slist *headers;
          char curl_errbuf[CURL_ERROR_SIZE];
  
 -        char   send_buffer[4096];
 +        char  *send_buffer;
 +        size_t send_buffer_size;
          size_t send_buffer_free;
          size_t send_buffer_fill;
          cdtime_t send_buffer_init_time;
@@@ -124,30 -110,17 +123,30 @@@ static int wh_callback_init (wh_callbac
                  return (-1);
          }
  
 +        if (cb->low_speed_limit > 0 && cb->low_speed_time > 0)
 +        {
 +                curl_easy_setopt (cb->curl, CURLOPT_LOW_SPEED_LIMIT,
 +                                  (long) (cb->low_speed_limit * cb->low_speed_time));
 +                curl_easy_setopt (cb->curl, CURLOPT_LOW_SPEED_TIME,
 +                                  (long) cb->low_speed_time);
 +        }
 +
 +#ifdef HAVE_CURLOPT_TIMEOUT_MS
 +        if (cb->timeout > 0)
 +                curl_easy_setopt (cb->curl, CURLOPT_TIMEOUT_MS, (long) cb->timeout);
 +#endif
 +
          curl_easy_setopt (cb->curl, CURLOPT_NOSIGNAL, 1L);
 -        curl_easy_setopt (cb->curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
 +        curl_easy_setopt (cb->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
  
-         headers = NULL;
-         headers = curl_slist_append (headers, "Accept:  */*");
+         cb->headers = NULL;
+         cb->headers = curl_slist_append (cb->headers, "Accept:  */*");
          if (cb->format == WH_FORMAT_JSON)
-                 headers = curl_slist_append (headers, "Content-Type: application/json");
+                 cb->headers = curl_slist_append (cb->headers, "Content-Type: application/json");
          else
-                 headers = curl_slist_append (headers, "Content-Type: text/plain");
-         headers = curl_slist_append (headers, "Expect:");
-         curl_easy_setopt (cb->curl, CURLOPT_HTTPHEADER, headers);
+                 cb->headers = curl_slist_append (cb->headers, "Content-Type: text/plain");
+         cb->headers = curl_slist_append (cb->headers, "Expect:");
+         curl_easy_setopt (cb->curl, CURLOPT_HTTPHEADER, cb->headers);
  
          curl_easy_setopt (cb->curl, CURLOPT_ERRORBUFFER, cb->curl_errbuf);
          curl_easy_setopt (cb->curl, CURLOPT_URL, cb->location);
@@@ -309,12 -262,14 +308,19 @@@ static void wh_callback_free (void *dat
  
          wh_flush_nolock (/* timeout = */ 0, cb);
  
 -        curl_easy_cleanup (cb->curl);
 +        if (cb->curl != NULL)
 +        {
 +                curl_easy_cleanup (cb->curl);
 +                cb->curl = NULL;
 +        }
+         if (cb->headers != NULL)
+         {
+                 curl_slist_free_all (cb->headers);
+                 cb->headers = NULL;
+         }
 +        sfree (cb->name);
          sfree (cb->location);
          sfree (cb->user);
          sfree (cb->pass);
@@@ -532,12 -522,16 +538,17 @@@ static int wh_config_node (oconfig_item
                  return (-1);
          }
          memset (cb, 0, sizeof (*cb));
 -        cb->location = NULL;
 -        cb->user = NULL;
 -        cb->pass = NULL;
 -        cb->credentials = NULL;
          cb->verify_peer = 1;
          cb->verify_host = 1;
 -        cb->cacert = NULL;
          cb->format = WH_FORMAT_COMMAND;
++<<<<<<< HEAD
 +        cb->sslversion = CURL_SSLVERSION_DEFAULT;
 +        cb->low_speed_limit = 0;
 +        cb->timeout = 0;
++=======
+         cb->curl = NULL;
+         cb->headers = NULL;
++>>>>>>> collectd-5.4
  
          pthread_mutex_init (&cb->send_lock, /* attr = */ NULL);