X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcurl_json.c;h=8f6382b844cd281e231a12358973dd8875520d05;hb=f374b72032a227a75b6bc9ae574cd28abbc16f24;hp=9cdd4fe80aa9476e4b25d1ea1d0c5d94c92cc62e;hpb=8a2be9037587c1b80a00ddb1d7d396d1d48ec37d;p=collectd.git diff --git a/src/curl_json.c b/src/curl_json.c index 9cdd4fe8..8f6382b8 100644 --- a/src/curl_json.c +++ b/src/curl_json.c @@ -562,7 +562,6 @@ static int cj_init_curl(cj_t *db) /* {{{ */ curl_easy_setopt(db->curl, CURLOPT_WRITEDATA, db); curl_easy_setopt(db->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT); curl_easy_setopt(db->curl, CURLOPT_ERRORBUFFER, db->curl_errbuf); - curl_easy_setopt(db->curl, CURLOPT_URL, db->url); curl_easy_setopt(db->curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(db->curl, CURLOPT_MAXREDIRS, 50L); @@ -716,10 +715,11 @@ static int cj_config_add_url(oconfig_item_t *ci) /* {{{ */ cb_name = ssnprintf_alloc("curl_json-%s-%s", db->instance, db->url ? db->url : db->sock); - user_data_t ud = {.data = db, .free_func = cj_free}; - plugin_register_complex_read(/* group = */ NULL, cb_name, cj_read, - /* interval = */ db->interval, &ud); + /* interval = */ db->interval, + &(user_data_t){ + .data = db, .free_func = cj_free, + }); sfree(cb_name); } else { cj_free(db); @@ -840,12 +840,13 @@ static int cj_curl_perform(cj_t *db) /* {{{ */ int status; long rc; char *url; - url = db->url; + + curl_easy_setopt(db->curl, CURLOPT_URL, db->url); status = curl_easy_perform(db->curl); if (status != CURLE_OK) { ERROR("curl_json plugin: curl_easy_perform failed with status %i: %s (%s)", - status, db->curl_errbuf, url); + status, db->curl_errbuf, db->url); return (-1); } if (db->stats != NULL)