From: Marc Fournier Date: Thu, 2 Apr 2015 16:25:42 +0000 (+0200) Subject: curl_json: allow Timeout to be set to 0 X-Git-Tag: collectd-5.5.0~56^2~8 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=bce14a848714aa347c0eab462e952d86c3347da6;p=collectd.git curl_json: allow Timeout to be set to 0 also use the per-instance interval or plugin_get_interval() as the default value, depending on which one is configured. --- diff --git a/src/curl_json.c b/src/curl_json.c index 4cd4aec9..292b262c 100644 --- a/src/curl_json.c +++ b/src/curl_json.c @@ -650,10 +650,15 @@ static int cj_init_curl (cj_t *db) /* {{{ */ curl_easy_setopt (db->curl, CURLOPT_HTTPHEADER, db->headers); if (db->post_body != NULL) curl_easy_setopt (db->curl, CURLOPT_POSTFIELDS, db->post_body); - curl_easy_setopt (db->curl, CURLOPT_TIMEOUT_MS, - db->timeout > 0 ? - db->timeout : - ( db->interval > 0 ? db->interval : cf_get_default_interval () )); + + if (db->timeout >= 0) + curl_easy_setopt (db->curl, CURLOPT_TIMEOUT_MS, db->timeout); + else if (db->interval > 0) + curl_easy_setopt (db->curl, CURLOPT_TIMEOUT_MS, + CDTIME_T_TO_MS(db->timeout)); + else + curl_easy_setopt (db->curl, CURLOPT_TIMEOUT_MS, + CDTIME_T_TO_MS(plugin_get_interval())); return (0); } /* }}} int cj_init_curl */ @@ -680,6 +685,8 @@ static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */ } memset (db, 0, sizeof (*db)); + db->timeout = -1; + if (strcasecmp ("URL", ci->key) == 0) status = cf_util_get_string (ci, &db->url); else if (strcasecmp ("Sock", ci->key) == 0)