diff options
author | Nathan Scott <nathans@redhat.com> | 2021-07-07 14:00:36 +1000 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2021-07-07 14:00:36 +1000 |
commit | 15a71f32fe1636d24bc8c2ae5e1eb689d2e28c7e (patch) | |
tree | 8ebea94be0d01f50f77c898614e9a78e3497e5e2 | |
parent | 93be3211aeb3bccc198d5d19596e198888c94d3e (diff) |
Add more defensive checks to PCP paths if sampling fails
-rw-r--r-- | pcp/Platform.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/pcp/Platform.c b/pcp/Platform.c index f10b128b..215a3ee0 100644 --- a/pcp/Platform.c +++ b/pcp/Platform.c @@ -336,6 +336,9 @@ pmAtomValue *Metric_instance(Metric metric, int inst, int offset, pmAtomValue *a * Start it off by passing offset -1 into the routine. */ bool Metric_iterate(Metric metric, int* instp, int* offsetp) { + if (!pcp->result) + return false; + pmValueSet* vset = pcp->result->vset[metric]; if (!vset || vset->numval <= 0) return false; @@ -892,8 +895,12 @@ void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) { } void Platform_gettime_monotonic(uint64_t* msec) { - struct timeval* tv = &pcp->result->timestamp; - *msec = ((uint64_t)tv->tv_sec * 1000) + ((uint64_t)tv->tv_usec / 1000); + if (pcp->result) { + struct timeval* tv = &pcp->result->timestamp; + *msec = ((uint64_t)tv->tv_sec * 1000) + ((uint64_t)tv->tv_usec / 1000); + } else { + *msec = 0; + } } Hashtable* Platform_dynamicMeters(void) { |