]> 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)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 17 Sep 2019 16:52:25 +0000 (19:52 +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 d39db759924239e31a16785ee82d6ead565e85aa..2f87c4ba4e6d8a6a4d2549f3441802b2e1950339 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, 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);
        }
 }