From: Florian Forster Date: Mon, 8 Sep 2014 09:19:26 +0000 (+0200) Subject: src/plugin.c: Parse "MaxReadInterval" with global_option_get_time(). X-Git-Tag: collectd-5.5.0~206^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7256d7b15948568c4e5d13d830c89be082d4db29;p=collectd.git src/plugin.c: Parse "MaxReadInterval" with global_option_get_time(). --- diff --git a/src/plugin.c b/src/plugin.c index 0da13d8a..5b9763ab 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -104,7 +104,9 @@ static c_avl_tree_t *data_sets; static char *plugindir = NULL; -#define DEFAULT_MAX_READ_INTERVAL 86400 +#ifndef DEFAULT_MAX_READ_INTERVAL +# define DEFAULT_MAX_READ_INTERVAL TIME_T_TO_CDTIME_T (86400) +#endif static c_heap_t *read_heap = NULL; static llist_t *read_list; static int read_loop = 1; @@ -112,7 +114,7 @@ static pthread_mutex_t read_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t read_cond = PTHREAD_COND_INITIALIZER; static pthread_t *read_threads = NULL; static int read_threads_num = 0; -static int max_read_interval = DEFAULT_MAX_READ_INTERVAL; +static cdtime_t max_read_interval = DEFAULT_MAX_READ_INTERVAL; static write_queue_t *write_queue_head; static write_queue_t *write_queue_tail; @@ -485,8 +487,8 @@ static void *plugin_read_thread (void __attribute__((unused)) *args) if (status != 0) { rf->rf_effective_interval *= 2; - if (rf->rf_effective_interval > TIME_T_TO_CDTIME_T (max_read_interval)) - rf->rf_effective_interval = TIME_T_TO_CDTIME_T (max_read_interval); + if (rf->rf_effective_interval > max_read_interval) + rf->rf_effective_interval = max_read_interval; NOTICE ("read-function of plugin `%s' failed. " "Will suspend it for %.3f seconds.", @@ -1543,19 +1545,15 @@ void plugin_init_all (void) le = le->next; } + max_read_interval = global_option_get_time ("MaxReadInterval", + DEFAULT_MAX_READ_INTERVAL); + /* Start read-threads */ if (read_heap != NULL) { const char *rt; int num; - max_read_interval = global_option_get_long ("MaxReadInterval", - DEFAULT_MAX_READ_INTERVAL); - if (max_read_interval <= 0) { - ERROR ("MaxReadInterval must be positive"); - max_read_interval = DEFAULT_MAX_READ_INTERVAL; - } - rt = global_option_get ("ReadThreads"); num = atoi (rt); if (num != -1)