From: Timo Sirainen Date: Tue, 17 Sep 2019 16:52:25 +0000 (+0300) Subject: lib-index: Add index alloc cache timeout to root ioloop X-Git-Tag: 2.3.9~146 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b8198a426099aef84d9f2c98aa69857fc691f093;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Add index alloc cache timeout to root ioloop The cache is a global one and the timeout shouldn't trigger until the global root ioloop is reached. This fixes a timeout leak / crash when index was opened in an inner ioloop. --- diff --git a/src/lib-index/mail-index-alloc-cache.c b/src/lib-index/mail-index-alloc-cache.c index d39db75992..2f87c4ba4e 100644 --- a/src/lib-index/mail-index-alloc-cache.c +++ b/src/lib-index/mail-index-alloc-cache.c @@ -237,8 +237,11 @@ void mail_index_alloc_cache_unref(struct mail_index **_index) *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); + /* Add to root ioloop in case we got here from an inner + ioloop which gets destroyed too early. */ + to_index = timeout_add_to(io_loop_get_root(), + INDEX_CACHE_TIMEOUT*1000/2, + index_removal_timeout, NULL); } }