summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 76e6392)
raw | patch | inline | side by side (parent: 76e6392)
author | Florian Forster <octo@collectd.org> | |
Tue, 13 Nov 2012 18:14:56 +0000 (19:14 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 14 Nov 2012 12:02:24 +0000 (13:02 +0100) |
Rather, let plugin_insert_read() wake up all the read threads.
This removes another usage of interval_g.
This removes another usage of interval_g.
src/plugin.c | patch | blob | history |
diff --git a/src/plugin.c b/src/plugin.c
index eedbc15af3461906e0d12dbc242d779f1c8d08c3..9d10631df22faec6939292fdec0fcba0cc6945c8 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
int rf_type;
int rc;
- /* Get the read function that needs to be read next. */
+ /* Get the read function that needs to be read next.
+ * We don't need to hold "read_lock" for the heap, but we need
+ * to call c_heap_get_root() and pthread_cond_wait() in the
+ * same protected block. */
+ pthread_mutex_lock (&read_lock);
rf = c_heap_get_root (read_heap);
if (rf == NULL)
{
- struct timespec abstime;
-
- now = cdtime ();
-
- CDTIME_T_TO_TIMESPEC (now + interval_g, &abstime);
-
- pthread_mutex_lock (&read_lock);
- pthread_cond_timedwait (&read_cond, &read_lock,
- &abstime);
- pthread_mutex_unlock (&read_lock);
+ pthread_cond_wait (&read_cond, &read_lock);
+ pthread_mutex_unlock (&read_lock);
continue;
}
+ pthread_mutex_unlock (&read_lock);
if ((rf->rf_interval.tv_sec == 0) && (rf->rf_interval.tv_nsec == 0))
{
/* This does not fail. */
llist_append (read_list, le);
+ /* Wake up all the read threads. */
+ pthread_cond_broadcast (&read_cond);
pthread_mutex_unlock (&read_lock);
return (0);
} /* int plugin_insert_read */