/*
* Private variables
*/
-static c_avl_tree_t *plugins_loaded = NULL;
+static c_avl_tree_t *plugins_loaded;
static llist_t *list_init;
static llist_t *list_write;
static llist_t *list_log;
static llist_t *list_notification;
-static fc_chain_t *pre_cache_chain = NULL;
-static fc_chain_t *post_cache_chain = NULL;
+static fc_chain_t *pre_cache_chain;
+static fc_chain_t *post_cache_chain;
static c_avl_tree_t *data_sets;
-static char *plugindir = NULL;
+static char *plugindir;
#ifndef DEFAULT_MAX_READ_INTERVAL
#define DEFAULT_MAX_READ_INTERVAL TIME_T_TO_CDTIME_T_STATIC(86400)
#endif
-static c_heap_t *read_heap = NULL;
+static c_heap_t *read_heap;
static llist_t *read_list;
static int read_loop = 1;
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 size_t read_threads_num = 0;
+static pthread_t *read_threads;
+static size_t read_threads_num;
static cdtime_t max_read_interval = DEFAULT_MAX_READ_INTERVAL;
static write_queue_t *write_queue_head;
static write_queue_t *write_queue_tail;
-static long write_queue_length = 0;
-static _Bool write_loop = 1;
+static long write_queue_length;
+static bool write_loop = true;
static pthread_mutex_t write_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t write_cond = PTHREAD_COND_INITIALIZER;
-static pthread_t *write_threads = NULL;
-static size_t write_threads_num = 0;
+static pthread_t *write_threads;
+static size_t write_threads_num;
static pthread_key_t plugin_ctx_key;
-static _Bool plugin_ctx_key_initialized = 0;
+static bool plugin_ctx_key_initialized;
-static long write_limit_high = 0;
-static long write_limit_low = 0;
+static long write_limit_high;
+static long write_limit_low;
-static derive_t stats_values_dropped = 0;
-static _Bool record_statistics = 0;
+static derive_t stats_values_dropped;
+static bool record_statistics;
/*
* Static functions
/* plugin_load_file loads the shared object "file" and calls its
* "module_register" function. Returns zero on success, non-zero otherwise. */
-static int plugin_load_file(char const *file, _Bool global) {
+static int plugin_load_file(char const *file, bool global) {
int flags = RTLD_NOW;
if (global)
flags |= RTLD_GLOBAL;
INFO("collectd: Stopping %" PRIsz " write threads.", write_threads_num);
pthread_mutex_lock(&write_lock);
- write_loop = 0;
+ write_loop = false;
DEBUG("plugin: stop_write_threads: Signalling `write_cond'");
pthread_cond_broadcast(&write_cond);
pthread_mutex_unlock(&write_lock);
ERROR("plugin_set_dir: strdup(\"%s\") failed", dir);
}
-static _Bool plugin_is_loaded(char const *name) {
+static bool plugin_is_loaded(char const *name) {
int status;
if (plugins_loaded == NULL)
}
#define BUFSIZE 512
-int plugin_load(char const *plugin_name, _Bool global) {
+int plugin_load(char const *plugin_name, bool global) {
DIR *dh;
const char *dir;
char filename[BUFSIZE] = "";
*/
if ((strcasecmp("perl", plugin_name) == 0) ||
(strcasecmp("python", plugin_name) == 0))
- global = 1;
+ global = true;
/* `cpu' should not match `cpufreq'. To solve this we add `.so' to the
* type when matching the filename */
uc_init();
if (IS_TRUE(global_option_get("CollectInternalStats"))) {
- record_statistics = 1;
+ record_statistics = true;
plugin_register_read("collectd", plugin_update_internal_statistics);
}
int status;
static c_complain_t no_write_complaint = C_COMPLAIN_INIT_STATIC;
- _Bool free_meta_data = 0;
+ bool free_meta_data = false;
assert(vl != NULL);
* this case matches and targets may add some and the calling function
* may not expect (and therefore free) that data. */
if (vl->meta == NULL)
- free_meta_data = 1;
+ free_meta_data = true;
if (list_write == NULL)
c_complain_once(LOG_WARNING, &no_write_complaint,
} else
fc_default_action(ds, vl);
- if ((free_meta_data != 0) && (vl->meta != NULL)) {
+ if ((free_meta_data == true) && (vl->meta != NULL)) {
meta_data_destroy(vl->meta);
vl->meta = NULL;
}
return (double)pos / (double)size;
} /* }}} double get_drop_probability */
-static _Bool check_drop_value(void) /* {{{ */
+static bool check_drop_value(void) /* {{{ */
{
- static cdtime_t last_message_time = 0;
+ static cdtime_t last_message_time;
static pthread_mutex_t last_message_lock = PTHREAD_MUTEX_INITIALIZER;
double p;
int status;
if (write_limit_high == 0)
- return 0;
+ return false;
p = get_drop_probability();
if (p == 0.0)
- return 0;
+ return false;
status = pthread_mutex_trylock(&last_message_lock);
if (status == 0) {
}
if (p == 1.0)
- return 1;
+ return true;
q = cdrand_d();
if (q > p)
- return 1;
+ return true;
else
- return 0;
-} /* }}} _Bool check_drop_value */
+ return false;
+} /* }}} bool check_drop_value */
int plugin_dispatch_values(value_list_t const *vl) {
int status;
__attribute__((sentinel)) int
plugin_dispatch_multivalue(value_list_t const *template, /* {{{ */
- _Bool store_percentage, int store_type, ...) {
+ bool store_percentage, int store_type, ...) {
value_list_t *vl;
int failed = 0;
gauge_t sum = 0.0;
break;
}
case NM_TYPE_BOOLEAN: {
- meta->nm_value.nm_boolean = *((_Bool *)value);
+ meta->nm_value.nm_boolean = *((bool *)value);
break;
}
default: {
}
int plugin_notification_meta_add_boolean(notification_t *n, const char *name,
- _Bool value) {
+ bool value) {
return plugin_notification_meta_add(n, name, NM_TYPE_BOOLEAN, &value);
}
void plugin_init_ctx(void) {
pthread_key_create(&plugin_ctx_key, plugin_ctx_destructor);
- plugin_ctx_key_initialized = 1;
+ plugin_ctx_key_initialized = true;
} /* void plugin_init_ctx */
plugin_ctx_t plugin_get_ctx(void) {