projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-5.7'
[collectd.git]
/
src
/
memcached.c
diff --git
a/src/memcached.c
b/src/memcached.c
index
36b3c9a
..
90f323f
100644
(file)
--- a/
src/memcached.c
+++ b/
src/memcached.c
@@
-67,6
+67,7
@@
static void memcached_free(void *arg) {
if (st->fd >= 0) {
shutdown(st->fd, SHUT_RDWR);
close(st->fd);
if (st->fd >= 0) {
shutdown(st->fd, SHUT_RDWR);
close(st->fd);
+ st->fd = -1;
}
sfree(st->name);
}
sfree(st->name);
@@
-163,9
+164,9
@@
static int memcached_connect_inet(memcached_t *st) {
}
/* Wait until connection establishes */
}
/* Wait until connection establishes */
- struct pollfd pollfd
;
- pollfd.fd = fd;
-
pollfd.events = POLLOUT
;
+ struct pollfd pollfd
= {
+ .fd = fd, .events = POLLOUT,
+
}
;
do
status = poll(&pollfd, 1, MEMCACHED_CONNECT_TIMEOUT);
while (status < 0 && errno == EINTR);
do
status = poll(&pollfd, 1, MEMCACHED_CONNECT_TIMEOUT);
while (status < 0 && errno == EINTR);
@@
-177,9
+178,8
@@
static int memcached_connect_inet(memcached_t *st) {
/* Check if all is good */
int socket_error;
/* Check if all is good */
int socket_error;
- socklen_t socket_error_len = sizeof(socket_error);
status = getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&socket_error,
status = getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&socket_error,
- &
socket_error_len
);
+ &
(socklen_t){sizeof(socket_error)}
);
if (status != 0 || socket_error != 0) {
close(fd);
fd = -1;
if (status != 0 || socket_error != 0) {
close(fd);
fd = -1;
@@
-219,9
+219,9
@@
static int memcached_query_daemon(char *buffer, size_t buffer_size,
return -1;
}
return -1;
}
- struct pollfd pollfd
;
- pollfd.fd = st->fd;
-
pollfd.events = POLLOUT
;
+ struct pollfd pollfd
= {
+ .fd = st->fd, .events = POLLOUT,
+
}
;
do
status = poll(&pollfd, 1, MEMCACHED_IO_TIMEOUT);
do
status = poll(&pollfd, 1, MEMCACHED_IO_TIMEOUT);
@@
-472,6
+472,13
@@
static int memcached_read(user_data_t *user_data) {
} else if (FIELD_IS("listen_disabled_num")) {
submit_derive("connections", "listen_disabled", atof(fields[2]), st);
}
} else if (FIELD_IS("listen_disabled_num")) {
submit_derive("connections", "listen_disabled", atof(fields[2]), st);
}
+ /*
+ * Total number of connections opened since the server started running
+ * Report this as connection rate.
+ */
+ else if (FIELD_IS("total_connections")) {
+ submit_derive("connections", "opened", atof(fields[2]), st);
+ }
/*
* Commands
/*
* Commands