dovecot-2.2: lib-index: Keep track of views and transactions in ...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jan 15 22:11:30 EET 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/3f352534af56
changeset: 17108:3f352534af56
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jan 15 22:11:22 2014 +0200
description:
lib-index: Keep track of views and transactions in linked lists.
This makes debugging easier.

diffstat:

 src/lib-index/mail-index-private.h             |   2 +-
 src/lib-index/mail-index-transaction-private.h |   1 +
 src/lib-index/mail-index-transaction.c         |   3 +++
 src/lib-index/mail-index-view-private.h        |   2 ++
 src/lib-index/mail-index-view.c                |  10 +++++-----
 src/lib-index/mail-index.c                     |   2 +-
 6 files changed, 13 insertions(+), 7 deletions(-)

diffs (123 lines):

diff -r 5abd643c0dd2 -r 3f352534af56 src/lib-index/mail-index-private.h
--- a/src/lib-index/mail-index-private.h	Wed Jan 15 15:07:50 2014 -0500
+++ b/src/lib-index/mail-index-private.h	Wed Jan 15 22:11:22 2014 +0200
@@ -214,7 +214,7 @@
 	uint32_t keywords_ext_id;
 	uint32_t modseq_ext_id;
 
-	unsigned int view_count;
+	struct mail_index_view *views;
 
 	/* Module-specific contexts. */
 	ARRAY(union mail_index_module_context *) module_contexts;
diff -r 5abd643c0dd2 -r 3f352534af56 src/lib-index/mail-index-transaction-private.h
--- a/src/lib-index/mail-index-transaction-private.h	Wed Jan 15 15:07:50 2014 -0500
+++ b/src/lib-index/mail-index-transaction-private.h	Wed Jan 15 22:11:22 2014 +0200
@@ -36,6 +36,7 @@
 };
 
 struct mail_index_transaction {
+	struct mail_index_transaction *prev, *next;
 	int refcount;
 
 	enum mail_index_transaction_flags flags;
diff -r 5abd643c0dd2 -r 3f352534af56 src/lib-index/mail-index-transaction.c
--- a/src/lib-index/mail-index-transaction.c	Wed Jan 15 15:07:50 2014 -0500
+++ b/src/lib-index/mail-index-transaction.c	Wed Jan 15 22:11:22 2014 +0200
@@ -4,6 +4,7 @@
 #include "ioloop.h"
 #include "array.h"
 #include "bsearch-insert-pos.h"
+#include "llist.h"
 #include "mail-index-private.h"
 #include "mail-transaction-log-private.h"
 #include "mail-index-transaction-private.h"
@@ -50,6 +51,7 @@
 
 	mail_index_transaction_reset_v(t);
 
+	DLLIST_REMOVE(&t->view->transactions_list, t);
 	array_free(&t->module_contexts);
 	mail_index_view_transaction_unref(t->view);
 	if (t->latest_view != NULL)
@@ -311,6 +313,7 @@
 
 	i_array_init(&t->module_contexts,
 		     I_MIN(5, mail_index_module_register.id));
+	DLLIST_PREPEND(&view->transactions_list, t);
 
 	if (hook_mail_index_transaction_created != NULL)
 		hook_mail_index_transaction_created(t);
diff -r 5abd643c0dd2 -r 3f352534af56 src/lib-index/mail-index-view-private.h
--- a/src/lib-index/mail-index-view-private.h	Wed Jan 15 15:07:50 2014 -0500
+++ b/src/lib-index/mail-index-view-private.h	Wed Jan 15 22:11:22 2014 +0200
@@ -44,6 +44,7 @@
 };
 
 struct mail_index_view {
+	struct mail_index_view *prev, *next;
 	int refcount;
 
 	struct mail_index_view_vfuncs v;
@@ -69,6 +70,7 @@
 	/* Module-specific contexts. */
 	ARRAY(union mail_index_view_module_context *) module_contexts;
 
+	struct mail_index_transaction *transactions_list;
 	int transactions;
 
 	unsigned int inconsistent:1;
diff -r 5abd643c0dd2 -r 3f352534af56 src/lib-index/mail-index-view.c
--- a/src/lib-index/mail-index-view.c	Wed Jan 15 15:07:50 2014 -0500
+++ b/src/lib-index/mail-index-view.c	Wed Jan 15 22:11:22 2014 +0200
@@ -3,6 +3,7 @@
 #include "lib.h"
 #include "array.h"
 #include "buffer.h"
+#include "llist.h"
 #include "mail-index-view-private.h"
 #include "mail-transaction-log.h"
 
@@ -47,7 +48,7 @@
 	i_array_init(&dest->module_contexts,
 		     I_MIN(5, mail_index_module_register.id));
 
-	dest->index->view_count++;
+	DLLIST_PREPEND(&dest->index->views, dest);
 }
 
 void mail_index_view_ref(struct mail_index_view *view)
@@ -58,9 +59,9 @@
 static void view_close(struct mail_index_view *view)
 {
 	i_assert(view->refcount == 0);
-	i_assert(view->index->view_count > 0);
+	i_assert(view->index->views != NULL);
 
-	view->index->view_count--;
+	DLLIST_REMOVE(&view->index->views, view);
 
 	mail_transaction_log_view_close(&view->log_view);
 
@@ -626,8 +627,7 @@
 
 	i_array_init(&view->module_contexts,
 		     I_MIN(5, mail_index_module_register.id));
-
-	index->view_count++;
+	DLLIST_PREPEND(&index->views, view);
 	return view;
 }
 
diff -r 5abd643c0dd2 -r 3f352534af56 src/lib-index/mail-index.c
--- a/src/lib-index/mail-index.c	Wed Jan 15 15:07:50 2014 -0500
+++ b/src/lib-index/mail-index.c	Wed Jan 15 22:11:22 2014 +0200
@@ -636,7 +636,7 @@
 		return;
 
 	i_assert(!index->syncing);
-	i_assert(index->view_count == 0);
+	i_assert(index->views == NULL);
 
 	if (index->map != NULL)
 		mail_index_unmap(&index->map);


More information about the dovecot-cvs mailing list