summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 917f878)
raw | patch | inline | side by side (parent: 917f878)
author | Florian Forster <octo@collectd.org> | |
Fri, 3 Feb 2012 09:54:58 +0000 (10:54 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Fri, 3 Feb 2012 09:54:58 +0000 (10:54 +0100) |
wg_send_buffer() is called from wg_flush_nolock(). When calling
wg_flush_nolock(), the thread has to hold cb->send_lock. Locking it again
will fail, but this condition is not checked for. Then the lock is
released twice which may result in concurrency issues.
Change-Id: Ie3062d50e6545adeb95b3a1938837c1f26835a56
wg_flush_nolock(), the thread has to hold cb->send_lock. Locking it again
will fail, but this condition is not checked for. Then the lock is
released twice which may result in concurrency issues.
Change-Id: Ie3062d50e6545adeb95b3a1938837c1f26835a56
src/write_graphite.c | patch | blob | history |
diff --git a/src/write_graphite.c b/src/write_graphite.c
index de460d7cfc0ba39e94ba4ae94fad4e45b25d34de..6b16bec215539245220fa662352604aad4ecef83 100644 (file)
--- a/src/write_graphite.c
+++ b/src/write_graphite.c
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);
}