From e117ee5d033765dca02541a406a565f007efe0c0 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sat, 10 Nov 2012 21:40:20 +0100 Subject: [PATCH] aggregation plugin: Handle a start-up condition gracefully. The resulting error message would confuse and annoy users. --- src/aggregation.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/aggregation.c b/src/aggregation.c index 985fa7c3..a9242234 100644 --- a/src/aggregation.c +++ b/src/aggregation.c @@ -606,6 +606,18 @@ static int agg_read (void) /* {{{ */ pthread_mutex_lock (&agg_instance_list_lock); + /* agg_instance_list_head only holds data, after the "write" callback has + * been called with a matching value list at least once. So on startup, + * there's a race between the aggregations read() and write() callback. If + * the read() callback is called first, agg_instance_list_head is NULL and + * "success" may be zero. This is expected and should not result in an error. + * Therefore we need to handle this case separately. */ + if (agg_instance_list_head == NULL) + { + pthread_mutex_unlock (&agg_instance_list_lock); + return (0); + } + for (this = agg_instance_list_head; this != NULL; this = this->next) { int status; -- 2.30.2