diff --git a/src/write_graphite.c b/src/write_graphite.c
index 502e22c31fa2ebfc47c8d172f41be3e2d1645c62..6b16bec215539245220fa662352604aad4ecef83 100644 (file)
--- a/src/write_graphite.c
+++ b/src/write_graphite.c
struct wg_callback
{
int sock_fd;
- struct hostent *server;
char *node;
char *service;
status,
strerror (errno));
- pthread_mutex_trylock (&cb->send_lock);
-
- DEBUG ("write_graphite plugin: closing socket and restting fd "
- "so reinit will occur");
close (cb->sock_fd);
cb->sock_fd = -1;
- pthread_mutex_unlock (&cb->send_lock);
-
return (-1);
}
return (0);
}
+/* NOTE: You must hold cb->send_lock when calling this function! */
static int wg_flush_nolock (cdtime_t timeout, struct wg_callback *cb)
{
int status;
cb = data;
+ pthread_mutex_lock (&cb->send_lock);
+
wg_flush_nolock (/* timeout = */ 0, cb);
close(cb->sock_fd);
+ cb->sock_fd = -1;
+
sfree(cb->node);
sfree(cb->service);
sfree(cb->prefix);
sfree(cb->postfix);
+ pthread_mutex_destroy (&cb->send_lock);
+
sfree(cb);
}
cb->service = NULL;
cb->prefix = NULL;
cb->postfix = NULL;
- cb->server = NULL;
cb->escape_char = '_';
pthread_mutex_init (&cb->send_lock, /* attr = */ NULL);