From: Timo Sirainen Date: Sun, 26 Feb 2012 02:59:36 +0000 (+0200) Subject: lib-storage: Removed min_timeout parameter from mailbox_notify_changes() X-Git-Tag: 2.2.alpha1~546 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9438ecaf1caee1bb33c8d7f638742875ac42c4e5;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Removed min_timeout parameter from mailbox_notify_changes() It's now internally taken from mailbox_idle_check_interval setting. --- diff --git a/src/imap/cmd-idle.c b/src/imap/cmd-idle.c index 04bc521d84..ca36ced377 100644 --- a/src/imap/cmd-idle.c +++ b/src/imap/cmd-idle.c @@ -253,14 +253,8 @@ bool cmd_idle(struct client_command_context *cmd) ctx->client = client; idle_add_keepalive_timeout(ctx); - if (client->mailbox != NULL) { - const struct mail_storage_settings *set; - - set = mailbox_get_settings(client->mailbox); - mailbox_notify_changes(client->mailbox, - set->mailbox_idle_check_interval, - idle_callback, ctx); - } + if (client->mailbox != NULL) + mailbox_notify_changes(client->mailbox, idle_callback, ctx); client_send_line(client, "+ idling"); io_remove(&client->io); diff --git a/src/lib-storage/index/imapc/imapc-storage.c b/src/lib-storage/index/imapc/imapc-storage.c index b92738071a..bf1a569009 100644 --- a/src/lib-storage/index/imapc/imapc-storage.c +++ b/src/lib-storage/index/imapc/imapc-storage.c @@ -705,10 +705,11 @@ static void imapc_idle_noop_callback(const struct imapc_command_reply *reply, static void imapc_notify_changes(struct mailbox *box) { struct imapc_mailbox *mbox = (struct imapc_mailbox *)box; + const struct mail_storage_settings *set = box->storage->set; struct imapc_command *cmd; enum imapc_capability capa; - if (box->notify_min_interval == 0) { + if (box->notify_callback == NULL) { if (mbox->to_idle_check != NULL) timeout_remove(&mbox->to_idle_check); return; @@ -728,7 +729,7 @@ static void imapc_notify_changes(struct mailbox *box) check for changes with NOOP every once in a while. */ i_assert(!imapc_client_is_running(mbox->storage->client)); mbox->to_idle_check = - timeout_add(box->notify_min_interval * 1000, + timeout_add(set->mailbox_idle_check_interval * 1000, imapc_idle_timeout, mbox); } } diff --git a/src/lib-storage/index/index-mailbox-check.c b/src/lib-storage/index/index-mailbox-check.c index 75dabe4fbf..7097a03245 100644 --- a/src/lib-storage/index/index-mailbox-check.c +++ b/src/lib-storage/index/index-mailbox-check.c @@ -67,12 +67,13 @@ static void notify_callback(struct mailbox *box) void index_mailbox_check_add(struct mailbox *box, const char *path) { struct index_mailbox_context *ibox = INDEX_STORAGE_CONTEXT(box); + const struct mail_storage_settings *set = box->storage->set; struct index_notify_file *file; struct stat st; struct io *io = NULL; struct index_notify_io *aio; - i_assert(box->notify_min_interval > 0); + i_assert(set->mailbox_idle_check_interval > 0); (void)io_add_notify(path, notify_callback, box, &io); if (io != NULL) { @@ -94,7 +95,7 @@ void index_mailbox_check_add(struct mailbox *box, const char *path) * when the filesystem is remote (NFS, ...) */ if (ibox->notify_to == NULL) { ibox->notify_to = - timeout_add(box->notify_min_interval * 1000, + timeout_add(set->mailbox_idle_check_interval * 1000, check_timeout, box); } } diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index c506d84958..f16bcffd84 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -241,7 +241,6 @@ struct mailbox { enum mailbox_feature enabled_features; /* Mailbox notification settings: */ - unsigned int notify_min_interval; mailbox_notify_callback_t *notify_callback; void *notify_context; diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index 5e48b4eecd..b5633c34be 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -1343,10 +1343,9 @@ int mailbox_sync(struct mailbox *box, enum mailbox_sync_flags flags) } #undef mailbox_notify_changes -void mailbox_notify_changes(struct mailbox *box, unsigned int min_interval, +void mailbox_notify_changes(struct mailbox *box, mailbox_notify_callback_t *callback, void *context) { - box->notify_min_interval = min_interval; box->notify_callback = callback; box->notify_context = context; @@ -1355,7 +1354,7 @@ void mailbox_notify_changes(struct mailbox *box, unsigned int min_interval, void mailbox_notify_changes_stop(struct mailbox *box) { - mailbox_notify_changes(box, 0, NULL, NULL); + mailbox_notify_changes(box, NULL, NULL); } struct mail_search_context * diff --git a/src/lib-storage/mail-storage.h b/src/lib-storage/mail-storage.h index c80883d86e..eae92c9a69 100644 --- a/src/lib-storage/mail-storage.h +++ b/src/lib-storage/mail-storage.h @@ -485,16 +485,16 @@ int mailbox_sync_deinit(struct mailbox_sync_context **ctx, int mailbox_sync(struct mailbox *box, enum mailbox_sync_flags flags); /* Call given callback function when something changes in the mailbox. */ -void mailbox_notify_changes(struct mailbox *box, unsigned int min_interval, +void mailbox_notify_changes(struct mailbox *box, mailbox_notify_callback_t *callback, void *context); #ifdef CONTEXT_TYPE_SAFETY -# define mailbox_notify_changes(box, min_interval, callback, context) \ +# define mailbox_notify_changes(box, callback, context) \ ({(void)(1 ? 0 : callback((struct mailbox *)NULL, context)); \ - mailbox_notify_changes(box, min_interval, \ + mailbox_notify_changes(box, \ (mailbox_notify_callback_t *)callback, context); }) #else -# define mailbox_notify_changes(box, min_interval, callback, context) \ - mailbox_notify_changes(box, min_interval, \ +# define mailbox_notify_changes(box, callback, context) \ + mailbox_notify_changes(box, \ (mailbox_notify_callback_t *)callback, context) #endif void mailbox_notify_changes_stop(struct mailbox *box); diff --git a/src/plugins/virtual/virtual-storage.c b/src/plugins/virtual/virtual-storage.c index d120d2548e..9babba9386 100644 --- a/src/plugins/virtual/virtual-storage.c +++ b/src/plugins/virtual/virtual-storage.c @@ -391,10 +391,8 @@ static void virtual_notify_changes(struct mailbox *box) if (box->notify_callback == NULL) mailbox_notify_changes_stop(bbox); - else { - mailbox_notify_changes(bbox, box->notify_min_interval, - virtual_notify_callback, box); - } + else + mailbox_notify_changes(bbox, virtual_notify_callback, box); } }