From: Florian Forster Date: Sat, 10 Nov 2012 20:40:20 +0000 (+0100) Subject: aggregation plugin: Handle a start-up condition gracefully. X-Git-Tag: collectd-5.2.0~24^2~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e117ee5d033765dca02541a406a565f007efe0c0;p=collectd.git aggregation plugin: Handle a start-up condition gracefully. The resulting error message would confuse and annoy users. --- 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;