]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Add index alloc cache timeout to root ioloop
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 17 Sep 2019 16:52:25 +0000 (19:52 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 23 Sep 2019 08:45:30 +0000 (11:45 +0300)
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.

src/lib-index/mail-index-alloc-cache.c

index b7c8e84b43bd48e727354b7824b7a096ef0a3526..227261adb47683ae6db37a8d479df7a39121fecf 100644 (file)
@@ -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, (void *)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, (void *)NULL);
        }
 }