]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: mailbox_search_notify() - Ensure that ioloop_time stays sufficiently...
authorMarco Bettini <marco.bettini@open-xchange.com>
Mon, 5 Jun 2023 15:41:13 +0000 (15:41 +0000)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 9 Jun 2023 10:54:32 +0000 (10:54 +0000)
This caters for the cases where the ioloop times is not actively refreshed
inside the processing loops (sort command, index search_next())

src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c

index fcbc36fa0b0fbd9590bf3961eb88a484431689e0..9604b57bb0ebcc92998ffd72046ab5e3c62071ec 100644 (file)
@@ -691,6 +691,7 @@ struct mail_search_context {
        normalizer_func_t *normalizer;
 
        struct timeval search_start_time, last_notify;
+       unsigned int search_notify_passes;
 
        /* if non-NULL, specifies that a search resulting is being updated.
           this can be used as a search optimization: if searched message
index 58778807e3d05f0127a0416e4bd3a91e5a47d97c..0e22438ba2f93b9218fe29a1a7050e5a792c96d5 100644 (file)
@@ -2554,8 +2554,13 @@ void mailbox_search_notify(struct mailbox *box, struct mail_search_context *ctx)
                ctx->last_notify = ctx->search_start_time;
 
        if (box->storage->callbacks.notify_progress == NULL ||
-           ctx->progress_hidden ||
-           ioloop_time - ctx->last_notify.tv_sec < MAIL_STORAGE_NOTIFY_INTERVAL_SECS)
+           ctx->progress_hidden)
+               return;
+
+       if (++ctx->search_notify_passes % 1024 == 0)
+               io_loop_time_refresh();
+
+       if (ioloop_time - ctx->last_notify.tv_sec < MAIL_STORAGE_NOTIFY_INTERVAL_SECS)
                return;
 
        struct mail_storage_progress_details dtl = {