Skip to content

Commit

Permalink
qrouting: Fix some buggy corner-cases
Browse files Browse the repository at this point in the history
    * fix un-initialized stat history intervals
    * improve handling for OOM during a dr_reload
  • Loading branch information
liviuchircu authored and razvancrainea committed Feb 11, 2020
1 parent a79abf0 commit 5238415
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions modules/qrouting/qr_stats.c
Expand Up @@ -49,11 +49,13 @@ qr_sample_t *create_history(void)
LM_ERR("oom\n");
return NULL;
}
memset(history, 0, sizeof *history);

for (tmp = history, i = 0; i < qr_n-1; tmp = tmp->next, ++i) {
tmp->next = shm_malloc(sizeof *tmp->next);
if (!tmp->next)
goto error;
memset(tmp->next, 0, sizeof *tmp->next);
}

tmp->next = history;
Expand Down Expand Up @@ -399,6 +401,8 @@ void qr_rld_prepare_part(void *param)

if (pl)
shm_free(pl);

qr_rld_list = NULL;
}

void qr_rld_finalize(void *param)
Expand All @@ -408,10 +412,9 @@ void qr_rld_finalize(void *param)
qr_rule_t *old_rules = NULL;
int i;

if (!qr_rld_list) {
LM_BUG("NULL qr_rld_list\n");
/* may happen if we ran OOM while preparing a new part */
if (!qr_rld_list)
return;
}

part_name = qr_rld_list->part_name[0];

Expand Down

0 comments on commit 5238415

Please sign in to comment.