Skip to content

Commit

Permalink
lib-stats: Allow unregistering + re-registering stats.
Browse files Browse the repository at this point in the history
Fixes:
Panic: stats_register() called after stats_alloc_size() was already called - this will break existing allocations

This could have happened with doveadm HTTP API when using multiple commands
in same HTTP connection.
  • Loading branch information
sirainen committed May 24, 2016
1 parent 5b47087 commit 838c70b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib-stats/stats.c
Expand Up @@ -68,8 +68,12 @@ void stats_unregister(struct stats_item **_item)
array_delete(&stats_items, idx, 1);

i_free(item);
if (array_count(&stats_items) == 0)
if (array_count(&stats_items) == 0) {
array_free(&stats_items);
/* all stats should have been freed by now. allow
re-registering and using stats. */
stats_allocated = FALSE;
}
}

struct stats *stats_alloc(pool_t pool)
Expand Down

0 comments on commit 838c70b

Please sign in to comment.