X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcurl_xml.c;h=7c422c71cc4db410e375174b554efa6b25c6ed2e;hb=ba0db2fe02e9d910b9150b561c9079ba0ba9801b;hp=169aaf9477d8e01f55a392c7c8fbbbbda776531b;hpb=79963d13c1884d1d92667cc502ad20758b084a12;p=collectd.git diff --git a/src/curl_xml.c b/src/curl_xml.c index 169aaf94..7c422c71 100644 --- a/src/curl_xml.c +++ b/src/curl_xml.c @@ -602,13 +602,15 @@ static int cx_curl_perform(cx_t *db, CURL *curl) /* {{{ */ long rc; char *ptr; char *url; - url = db->url; db->buffer_fill = 0; + + curl_easy_setopt(db->curl, CURLOPT_URL, db->url); + status = curl_easy_perform(curl); if (status != CURLE_OK) { ERROR("curl_xml 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) @@ -817,7 +819,6 @@ static int cx_init_curl(cx_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); @@ -966,10 +967,11 @@ static int cx_config_add_url(oconfig_item_t *ci) /* {{{ */ cb_name = ssnprintf_alloc("curl_xml-%s-%s", db->instance, db->url); - user_data_t ud = {.data = db, .free_func = cx_free}; - plugin_register_complex_read(/* group = */ "curl_xml", cb_name, cx_read, - /* interval = */ 0, &ud); + /* interval = */ 0, + &(user_data_t){ + .data = db, .free_func = cx_free, + }); sfree(cb_name); } else { cx_free(db);