summaryrefslogtreecommitdiffstats
path: root/DynamicMeter.c
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2021-07-12 16:51:19 +1000
committerNathan Scott <nathans@redhat.com>2021-07-14 11:58:46 +1000
commitbf853addc3e4b855cc8fb09a6558733d12548fbe (patch)
treef09dce3297b7fe05f0169d6f3ea3a5ddede4e9b7 /DynamicMeter.c
parenta4764902829d2a25a0e27c31824274362e11adea (diff)
Ensure PCP dynamic metric configuration definition uniqueness
It can happen that pcp-htop is presented multiple definitions of the same dynamic meter, e.g. if /etc/pcp/htop/meters has a definition matching one in ~/.config/htop/meters - instead of exiting with a duplicate metric error provide more meaningful diagnostics (on close) and also just skip over such entries. System files override home directories which overrides those found below the current working directory. Also fix the derived metric error diagnostic; because this is using CRT_fatalError, which is like perror(3), we must give a meaningful prefix (like program name) at the string end.
Diffstat (limited to 'DynamicMeter.c')
-rw-r--r--DynamicMeter.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/DynamicMeter.c b/DynamicMeter.c
index 605bbc3d..0b4063f2 100644
--- a/DynamicMeter.c
+++ b/DynamicMeter.c
@@ -48,16 +48,16 @@ static void DynamicMeter_compare(ht_key_t key, void* value, void* data) {
}
}
-bool DynamicMeter_search(const ProcessList* pl, const char* name, unsigned int* key) {
+bool DynamicMeter_search(Hashtable* dynamics, const char* name, unsigned int* key) {
DynamicIterator iter = { .key = 0, .name = name, .found = false };
- if (pl->dynamicMeters)
- Hashtable_foreach(pl->dynamicMeters, DynamicMeter_compare, &iter);
+ if (dynamics)
+ Hashtable_foreach(dynamics, DynamicMeter_compare, &iter);
*key = iter.key;
return iter.found;
}
-const char* DynamicMeter_lookup(const ProcessList* pl, unsigned int key) {
- const DynamicMeter* meter = Hashtable_get(pl->dynamicMeters, key);
+const char* DynamicMeter_lookup(Hashtable* dynamics, unsigned int key) {
+ const DynamicMeter* meter = Hashtable_get(dynamics, key);
return meter ? meter->name : NULL;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy