Skip to content

Commit

Permalink
Fix stats calc and lookup error path
Browse files Browse the repository at this point in the history
- If a set is not being updated, the set_stats command
  will get a divide by zero error

- The lookup error path may assert if a lookup completes
  for a set already present in the set tree.
  • Loading branch information
tom95858 committed Jul 8, 2023
1 parent 636a1c6 commit 362b104
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions ldms/src/core/ldms_xprt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2593,6 +2593,7 @@ static void handle_rendezvous_lookup(zap_ep_t zep, zap_event_t ev,

if (lset) {
rc = EEXIST;
lset = NULL; /* So error path won't try to delete it */
ref_put(&lset->ref, "__ldms_find_local_set");
/* unmap ev->map, it is not used */
zap_unmap(ev->map);
Expand Down
10 changes: 8 additions & 2 deletions ldms/src/ldmsd/ldmsd_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -7195,7 +7195,10 @@ static char * __set_stats_as_json(size_t *json_sz)
rc = regexec(&match->regex, prd_set->inst_name, 0, NULL, 0);
if (rc)
continue;
freq = 1000000 / (double)prd_set->updt_interval;
if (prd_set->updt_interval)
freq = 1000000.0 / (double)prd_set->updt_interval;
else
freq = 0.0;
if (prd_set->set) {
data_sz = ldms_set_data_sz_get(prd_set->set);
set_load += data_sz * freq;
Expand All @@ -7212,7 +7215,10 @@ static char * __set_stats_as_json(size_t *json_sz)
ldmsd_prdcr_set_t prd_set;
for (prd_set = ldmsd_prdcr_set_first(ref->prdcr); prd_set;
prd_set = ldmsd_prdcr_set_next(prd_set)) {
freq = 1000000 / (double)prd_set->updt_interval;
if (prd_set->updt_interval)
freq = 1000000.0 / (double)prd_set->updt_interval;
else
freq = 0.0;
if (prd_set->set) {
data_sz = ldms_set_data_sz_get(prd_set->set);
set_load += data_sz * freq;
Expand Down

0 comments on commit 362b104

Please sign in to comment.