From bce14a848714aa347c0eab462e952d86c3347da6 Mon Sep 17 00:00:00 2001 From: Marc Fournier Date: Thu, 2 Apr 2015 18:25:42 +0200 Subject: [PATCH] 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. --- src/curl_json.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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) -- 2.30.2