dovecot-2.0: lib-index: When a closed index's refcount drops to ...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Feb 20 11:45:56 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/3c0d86e79040
changeset: 10783:3c0d86e79040
user: Timo Sirainen <tss at iki.fi>
date: Sat Feb 20 10:11:42 2010 +0200
description:
lib-index: When a closed index's refcount drops to 0, free it immediately.
diffstat:
src/lib-index/mail-index-alloc-cache.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diffs (46 lines):
diff -r cdced48a276a -r 3c0d86e79040 src/lib-index/mail-index-alloc-cache.c
--- a/src/lib-index/mail-index-alloc-cache.c Sat Feb 20 09:47:41 2010 +0200
+++ b/src/lib-index/mail-index-alloc-cache.c Sat Feb 20 10:11:42 2010 +0200
@@ -94,6 +94,9 @@
if (match != NULL) {
/* already found the index. we're just going through
the rest of them to drop 0 refcounts */
+ } else if (rec->refcount == 0 && rec->index->open_count == 0) {
+ /* index is already closed. don't even try to
+ reuse it. */
} else if (index_dir != NULL && rec->index_dir_ino != 0) {
if (st.st_ino == rec->index_dir_ino &&
CMP_DEV_T(st.st_dev, rec->index_dir_dev)) {
@@ -164,12 +167,15 @@
void mail_index_alloc_cache_unref(struct mail_index **_index)
{
struct mail_index *index = *_index;
- struct mail_index_alloc_cache_list *list;
+ struct mail_index_alloc_cache_list *list, **listp;
*_index = NULL;
- for (list = indexes; list != NULL; list = list->next) {
- if (list->index == index)
+ list = NULL;
+ for (listp = &indexes; *listp != NULL; listp = &(*listp)->next) {
+ if ((*listp)->index == index) {
+ list = *listp;
break;
+ }
}
i_assert(list != NULL);
@@ -177,7 +183,12 @@
list->refcount--;
list->destroy_time = ioloop_time + INDEX_CACHE_TIMEOUT;
- if (to_index == NULL) {
+
+ if (list->refcount == 0 && index->open_count == 0) {
+ /* index was already closed. don't even try to cache it. */
+ *listp = list->next;
+ mail_index_alloc_cache_list_free(list);
+ } else if (to_index == NULL) {
to_index = timeout_add(INDEX_CACHE_TIMEOUT*1000/2,
index_removal_timeout, NULL);
}
More information about the dovecot-cvs
mailing list