X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fbind.c;h=c5327f14b8aaeed5ad687705e6b14e69ca0b675e;hb=f701e685eab83f37ecc6501d7dbe4eb941a454bb;hp=5324ceb16e0776366ae63e7c01124b9240a7f24b;hpb=5d0ef486144dea177f42f2d8ff88dd83adb2d367;p=collectd.git diff --git a/src/bind.c b/src/bind.c index 5324ceb1..c5327f14 100644 --- a/src/bind.c +++ b/src/bind.c @@ -109,6 +109,7 @@ static int global_server_stats = 1; static int global_zone_maint_stats = 1; static int global_resolver_stats = 0; static int global_memory_stats = 1; +static int timeout = -1; static cb_view_t *views = NULL; static size_t views_num = 0; @@ -266,7 +267,7 @@ static void submit (time_t ts, const char *plugin_instance, /* {{{ */ if (type_instance) { sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance)); - replace_special (vl.plugin_instance, sizeof (vl.plugin_instance)); + replace_special (vl.type_instance, sizeof (vl.type_instance)); } plugin_dispatch_values(&vl); } /* }}} void submit */ @@ -762,7 +763,7 @@ static int bind_xml_stats_handle_zone (int version, xmlDoc *doc, /* {{{ */ xmlFree (zone_name); zone_name = NULL; - if (j >= views->zones_num) + if (j >= view->zones_num) return (0); zone_name = view->zones[j]; @@ -1665,7 +1666,7 @@ static int bind_config_add_view (oconfig_item_t *ci) /* {{{ */ if (tmp->name == NULL) { ERROR ("bind plugin: strdup failed."); - free (tmp); + sfree (views); return (-1); } @@ -1725,6 +1726,8 @@ static int bind_config (oconfig_item_t *ci) /* {{{ */ bind_config_add_view (child); else if (strcasecmp ("ParseTime", child->key) == 0) cf_util_get_boolean (child, &config_parse_time); + else if (strcasecmp ("Timeout", child->key) == 0) + cf_util_get_int (child, &timeout); else { WARNING ("bind plugin: Unknown configuration option " @@ -1754,6 +1757,11 @@ static int bind_init (void) /* {{{ */ curl_easy_setopt (curl, CURLOPT_URL, (url != NULL) ? url : BIND_DEFAULT_URL); curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt (curl, CURLOPT_MAXREDIRS, 50L); +#ifdef HAVE_CURLOPT_TIMEOUT_MS + curl_easy_setopt (curl, CURLOPT_TIMEOUT_MS, (timeout >= 0) ? + (long) timeout : CDTIME_T_TO_MS(plugin_get_interval())); +#endif + return (0); } /* }}} int bind_init */