changeset 19510:c3bd02a27e63

stats: Avoid assert-crash with dsync. dsync creates two mail_users and they're deinited at the same time. stats_global_user isn't set after the first one is deinited, so the next deinit crashed because it wasn't set. Fixes: Panic: file stats-plugin.c: line 324 (stats_user_deinit): assertion failed: (stats_global_user == user)
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 13 Dec 2015 12:33:20 +0200
parents 9e4b2b433540
children e7c4ee19a36e
files src/plugins/stats/stats-plugin.c
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/stats/stats-plugin.c	Fri Dec 11 17:40:36 2015 +0200
+++ b/src/plugins/stats/stats-plugin.c	Sun Dec 13 12:33:20 2015 +0200
@@ -319,13 +319,13 @@
 	struct stats_connection *stats_conn = suser->stats_conn;
 
 	i_assert(stats_user_count > 0);
-	if (--stats_user_count == 0) {
+
+	stats_user_count--;
+	if (stats_global_user != NULL) {
 		/* we were updating the session lazily. do one final update. */
 		i_assert(stats_global_user == user);
 		stats_add_session(user);
 		stats_global_user = NULL;
-	} else {
-		i_assert(stats_global_user == NULL);
 	}
 
 	io_loop_context_remove_callbacks(suser->ioloop_ctx,