]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-stats: Allow unregistering + re-registering stats.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 24 May 2016 12:52:37 +0000 (15:52 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 24 May 2016 12:52:37 +0000 (15:52 +0300)
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.

src/lib-stats/stats.c

index 258c097f357661c98834307565e97a6155b4de3f..30588035e8649a67c2586d7c2b8fa6efd126ad96 100644 (file)
@@ -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)