From e941b5a3787f6ea48ac25437e09e61ae5d698915 Mon Sep 17 00:00:00 2001 From: Calle Wilund Date: Mon, 11 May 2015 19:49:27 +0200 Subject: [PATCH] Collectd: Make sure get_instance_ids only returns active id:s --- core/scollectd.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/scollectd.cc b/core/scollectd.cc index 5d6e39f664..3d47d82eda 100644 --- a/core/scollectd.cc +++ b/core/scollectd.cc @@ -392,10 +392,15 @@ public: } std::vector get_instance_ids() { - std::vector res(_values.size()); - int pos = 0; + std::vector res; for (auto i: _values) { - res[pos++] = i.first; + // Need to check for empty value_list, since unreg is two-stage. + // Not an issue for most uses, but unit testing etc that would like + // fully deterministic operation here would like us to only return + // actually active ids + if (i.second) { + res.emplace_back(i.first); + } } return res; }