diff --git a/src/write_graphite.c b/src/write_graphite.c
index 783b1f5b9f933951bf37b8b68ffcb3685c11ef57..6c8a977f98770f0a6772c76c153faac667e55a2e 100644 (file)
--- a/src/write_graphite.c
+++ b/src/write_graphite.c
/**
* collectd - src/write_graphite.c
- * Copyright (C) 2011 Scott Sanders
+ * Copyright (C) 2012 Pierre-Yves Ritschard
+ * Copyright (C) 2011 Scott Sanders
+ * Copyright (C) 2009 Paul Sadauskas
+ * Copyright (C) 2009 Doug MacEachern
+ * Copyright (C) 2007-2012 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
- * Author:
- * Scott Sanders <scott@jssjr.com>
+ * Authors:
+ * Florian octo Forster <octo at collectd.org>
+ * Doug MacEachern <dougm at hyperic.com>
+ * Paul Sadauskas <psadauskas at gmail.com>
+ * Scott Sanders <scott at jssjr.com>
+ * Pierre-Yves Ritschard <pyr at spootnik.org>
*
- * based on the excellent write_http plugin
+ * Based on the write_http plugin.
**/
/* write_graphite plugin configuation example
# define WG_DEFAULT_SERVICE "2003"
#endif
+#ifndef WG_DEFAULT_ESCAPE
+# define WG_DEFAULT_ESCAPE '_'
+#endif
+
#ifndef WG_SEND_BUF_SIZE
# define WG_SEND_BUF_SIZE 4096
#endif
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 = '_';
+ cb->escape_char = WG_DEFAULT_ESCAPE;
pthread_mutex_init (&cb->send_lock, /* attr = */ NULL);