From: Marco Bettini Date: Mon, 5 Jun 2023 15:41:13 +0000 (+0000) Subject: lib-storage: mailbox_search_notify() - Ensure that ioloop_time stays sufficiently... X-Git-Tag: 2.4.0~2696 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b59a186c9222d69908ec532d0a5abcca7ad3319b;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: mailbox_search_notify() - Ensure that ioloop_time stays sufficiently up to date This caters for the cases where the ioloop times is not actively refreshed inside the processing loops (sort command, index search_next()) --- diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index fcbc36fa0b..9604b57bb0 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -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 diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index 58778807e3..0e22438ba2 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -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 = {