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 #3158 from smortex/riemann-meta-data
[collectd.git]
/
src
/
pinba.c
diff --git
a/src/pinba.c
b/src/pinba.c
index
57ccc7a
..
61d226c
100644
(file)
--- a/
src/pinba.c
+++ b/
src/pinba.c
@@
-25,8
+25,8
@@
#include "collectd.h"
#include "collectd.h"
-#include "common.h"
#include "plugin.h"
#include "plugin.h"
+#include "utils/common/common.h"
#include <netdb.h>
#include <poll.h>
#include <netdb.h>
#include <poll.h>
@@
-99,15
+99,15
@@
typedef struct pinba_statnode_s pinba_statnode_t;
* Module global variables
*/
/* {{{ */
* Module global variables
*/
/* {{{ */
-static pinba_statnode_t *stat_nodes
= NULL
;
-static unsigned int stat_nodes_num
= 0
;
+static pinba_statnode_t *stat_nodes;
+static unsigned int stat_nodes_num;
static pthread_mutex_t stat_nodes_lock;
static pthread_mutex_t stat_nodes_lock;
-static char *conf_node
= NULL
;
-static char *conf_service
= NULL
;
+static char *conf_node;
+static char *conf_service;
-static
_Bool collector_thread_running = 0
;
-static
_Bool collector_thread_do_shutdown = 0
;
+static
bool collector_thread_running
;
+static
bool collector_thread_do_shutdown
;
static pthread_t collector_thread_id;
/* }}} */
static pthread_t collector_thread_id;
/* }}} */
@@
-280,9
+280,6
@@
static int pb_del_socket(pinba_socket_t *s, /* {{{ */
static int pb_add_socket(pinba_socket_t *s, /* {{{ */
const struct addrinfo *ai) {
static int pb_add_socket(pinba_socket_t *s, /* {{{ */
const struct addrinfo *ai) {
- int fd;
- int tmp;
- int status;
if (s->fd_num == PINBA_MAX_SOCKETS) {
WARNING("pinba plugin: Sorry, you have hit the built-in limit of "
if (s->fd_num == PINBA_MAX_SOCKETS) {
WARNING("pinba plugin: Sorry, you have hit the built-in limit of "
@@
-292,27
+289,20
@@
static int pb_add_socket(pinba_socket_t *s, /* {{{ */
return -1;
}
return -1;
}
- fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+
int
fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (fd < 0) {
if (fd < 0) {
- char errbuf[1024];
- ERROR("pinba plugin: socket(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("pinba plugin: socket(2) failed: %s", STRERRNO);
return 0;
}
return 0;
}
- tmp = 1;
- status = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp));
+ int status = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &(int){1}, sizeof(int));
if (status != 0) {
if (status != 0) {
- char errbuf[1024];
- WARNING("pinba plugin: setsockopt(SO_REUSEADDR) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("pinba plugin: setsockopt(SO_REUSEADDR) failed: %s", STRERRNO);
}
status = bind(fd, ai->ai_addr, ai->ai_addrlen);
if (status != 0) {
}
status = bind(fd, ai->ai_addr, ai->ai_addrlen);
if (status != 0) {
- char errbuf[1024];
- ERROR("pinba plugin: bind(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("pinba plugin: bind(2) failed: %s", STRERRNO);
close(fd);
return 0;
}
close(fd);
return 0;
}
@@
-414,7
+404,6
@@
static int pinba_udp_read_callback_fn(int sock) /* {{{ */
status = recvfrom(sock, buffer, buffer_size - 1, MSG_DONTWAIT,
/* from = */ NULL, /* from len = */ 0);
if (status < 0) {
status = recvfrom(sock, buffer, buffer_size - 1, MSG_DONTWAIT,
/* from = */ NULL, /* from len = */ 0);
if (status < 0) {
- char errbuf[1024];
if ((errno == EINTR)
#ifdef EWOULDBLOCK
if ((errno == EINTR)
#ifdef EWOULDBLOCK
@@
-424,8
+413,7
@@
static int pinba_udp_read_callback_fn(int sock) /* {{{ */
continue;
}
continue;
}
- WARNING("pinba plugin: recvfrom(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("pinba plugin: recvfrom(2) failed: %s", STRERRNO);
return -1;
} else if (status == 0) {
DEBUG("pinba plugin: recvfrom(2) returned unexpected status zero.");
return -1;
} else if (status == 0) {
DEBUG("pinba plugin: recvfrom(2) returned unexpected status zero.");
@@
-469,13
+457,10
@@
static int receive_loop(void) /* {{{ */
{
continue;
} else if (status < 0) {
{
continue;
} else if (status < 0) {
- char errbuf[1024];
-
if ((errno == EINTR) || (errno == EAGAIN))
continue;
if ((errno == EINTR) || (errno == EAGAIN))
continue;
- ERROR("pinba plugin: poll(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("pinba plugin: poll(2) failed: %s", STRERRNO);
pinba_socket_free(s);
return -1;
}
pinba_socket_free(s);
return -1;
}
@@
-501,7
+486,7
@@
static void *collector_thread(void *arg) /* {{{ */
receive_loop();
memset(&collector_thread_id, 0, sizeof(collector_thread_id));
receive_loop();
memset(&collector_thread_id, 0, sizeof(collector_thread_id));
- collector_thread_running =
0
;
+ collector_thread_running =
false
;
pthread_exit(NULL);
return NULL;
} /* }}} void *collector_thread */
pthread_exit(NULL);
return NULL;
} /* }}} void *collector_thread */
@@
-593,12
+578,10
@@
static int plugin_init(void) /* {{{ */
/* attrs = */ NULL, collector_thread,
/* args = */ NULL, "pinba collector");
if (status != 0) {
/* attrs = */ NULL, collector_thread,
/* args = */ NULL, "pinba collector");
if (status != 0) {
- char errbuf[1024];
- ERROR("pinba plugin: pthread_create(3) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("pinba plugin: pthread_create(3) failed: %s", STRERRNO);
return -1;
}
return -1;
}
- collector_thread_running =
1
;
+ collector_thread_running =
true
;
return 0;
} /* }}} */
return 0;
} /* }}} */
@@
-609,17
+592,15
@@
static int plugin_shutdown(void) /* {{{ */
int status;
DEBUG("pinba plugin: Shutting down collector thread.");
int status;
DEBUG("pinba plugin: Shutting down collector thread.");
- collector_thread_do_shutdown =
1
;
+ collector_thread_do_shutdown =
true
;
status = pthread_join(collector_thread_id, /* retval = */ NULL);
if (status != 0) {
status = pthread_join(collector_thread_id, /* retval = */ NULL);
if (status != 0) {
- char errbuf[1024];
- ERROR("pinba plugin: pthread_join(3) failed: %s",
- sstrerror(status, errbuf, sizeof(errbuf)));
+ ERROR("pinba plugin: pthread_join(3) failed: %s", STRERROR(status));
}
}
- collector_thread_running =
0
;
- collector_thread_do_shutdown =
0
;
+ collector_thread_running =
false
;
+ collector_thread_do_shutdown =
false
;
} /* if (collector_thread_running) */
return 0;
} /* if (collector_thread_running) */
return 0;