projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #2733 from elfiesmelfie/feat_pcie_aer
[collectd.git]
/
src
/
statsd.c
diff --git
a/src/statsd.c
b/src/statsd.c
index
70c1a75
..
6fbfd18
100644
(file)
--- a/
src/statsd.c
+++ b/
src/statsd.c
@@
-61,22
+61,22
@@
struct statsd_metric_s {
};
typedef struct statsd_metric_s statsd_metric_t;
};
typedef struct statsd_metric_s statsd_metric_t;
-static c_avl_tree_t *metrics_tree
= NULL
;
+static c_avl_tree_t *metrics_tree;
static pthread_mutex_t metrics_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_t network_thread;
static bool network_thread_running;
static bool network_thread_shutdown;
static pthread_mutex_t metrics_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_t network_thread;
static bool network_thread_running;
static bool network_thread_shutdown;
-static char *conf_node
= NULL
;
-static char *conf_service
= NULL
;
+static char *conf_node;
+static char *conf_service;
static bool conf_delete_counters;
static bool conf_delete_timers;
static bool conf_delete_gauges;
static bool conf_delete_sets;
static bool conf_delete_counters;
static bool conf_delete_timers;
static bool conf_delete_gauges;
static bool conf_delete_sets;
-static double *conf_timer_percentile
= NULL
;
+static double *conf_timer_percentile;
static size_t conf_timer_percentile_num;
static bool conf_counter_sum;
static size_t conf_timer_percentile_num;
static bool conf_counter_sum;
@@
-352,9
+352,8
@@
static int statsd_handle_set(char const *name, /* {{{ */
status = c_avl_insert(metric->set, set_key, /* value = */ NULL);
if (status < 0) {
pthread_mutex_unlock(&metrics_lock);
status = c_avl_insert(metric->set, set_key, /* value = */ NULL);
if (status < 0) {
pthread_mutex_unlock(&metrics_lock);
- if (status < 0)
- ERROR("statsd plugin: c_avl_insert (\"%s\") failed with status %i.",
- set_key, status);
+ ERROR("statsd plugin: c_avl_insert (\"%s\") failed with status %i.",
+ set_key, status);
sfree(set_key);
return -1;
} else if (status > 0) /* key already exists */
sfree(set_key);
return -1;
} else if (status > 0) /* key already exists */
@@
-490,8
+489,8
@@
static int statsd_network_init(struct pollfd **ret_fds, /* {{{ */
int fd;
struct pollfd *tmp;
int fd;
struct pollfd *tmp;
- char
dbg
_node[NI_MAXHOST];
- char
dbg
_service[NI_MAXSERV];
+ char
str
_node[NI_MAXHOST];
+ char
str
_service[NI_MAXSERV];
fd = socket(ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol);
if (fd < 0) {
fd = socket(ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol);
if (fd < 0) {
@@
-499,15
+498,16
@@
static int statsd_network_init(struct pollfd **ret_fds, /* {{{ */
continue;
}
continue;
}
- getnameinfo(ai_ptr->ai_addr, ai_ptr->ai_addrlen,
dbg_node, sizeof(dbg
_node),
-
dbg_service, sizeof(dbg
_service),
+ getnameinfo(ai_ptr->ai_addr, ai_ptr->ai_addrlen,
str_node, sizeof(str
_node),
+
str_service, sizeof(str
_service),
NI_DGRAM | NI_NUMERICHOST | NI_NUMERICSERV);
NI_DGRAM | NI_NUMERICHOST | NI_NUMERICSERV);
- DEBUG("statsd plugin: Trying to bind to [%s]:%s ...",
dbg
_node,
-
dbg
_service);
+ DEBUG("statsd plugin: Trying to bind to [%s]:%s ...",
str
_node,
+
str
_service);
status = bind(fd, ai_ptr->ai_addr, ai_ptr->ai_addrlen);
if (status != 0) {
status = bind(fd, ai_ptr->ai_addr, ai_ptr->ai_addrlen);
if (status != 0) {
- ERROR("statsd plugin: bind(2) failed: %s", STRERRNO);
+ ERROR("statsd plugin: bind(2) to [%s]:%s failed: %s", str_node,
+ str_service, STRERRNO);
close(fd);
continue;
}
close(fd);
continue;
}
@@
-666,7
+666,7
@@
static int statsd_init(void) /* {{{ */
return status;
}
}
return status;
}
}
- network_thread_running =
1
;
+ network_thread_running =
true
;
pthread_mutex_unlock(&metrics_lock);
pthread_mutex_unlock(&metrics_lock);
@@
-876,11
+876,11
@@
static int statsd_shutdown(void) /* {{{ */
void *value;
if (network_thread_running) {
void *value;
if (network_thread_running) {
- network_thread_shutdown =
1
;
+ network_thread_shutdown =
true
;
pthread_kill(network_thread, SIGTERM);
pthread_join(network_thread, /* retval = */ NULL);
}
pthread_kill(network_thread, SIGTERM);
pthread_join(network_thread, /* retval = */ NULL);
}
- network_thread_running =
0
;
+ network_thread_running =
false
;
pthread_mutex_lock(&metrics_lock);
pthread_mutex_lock(&metrics_lock);