Mercurial > dovecot > original-hg > dovecot-1.2
changeset 3983:565e3040a9f5 HEAD
Call file_dotlock_touch() once in a while so other process won't override
the conversion lock.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 05 Feb 2006 14:59:01 +0200 |
parents | 15c48c43cc75 |
children | 882ec6cc5970 |
files | src/plugins/convert/convert-storage.c |
diffstat | 1 files changed, 19 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/convert/convert-storage.c Sun Feb 05 14:58:05 2006 +0200 +++ b/src/plugins/convert/convert-storage.c Sun Feb 05 14:59:01 2006 +0200 @@ -35,7 +35,8 @@ return mailbox_sync_deinit(&ctx, &status); } -static int mailbox_copy_mails(struct mailbox *srcbox, struct mailbox *destbox) +static int mailbox_copy_mails(struct mailbox *srcbox, struct mailbox *destbox, + struct dotlock *dotlock) { struct mail_search_context *ctx; struct mailbox_transaction_context *src_trans, *dest_trans; @@ -62,6 +63,12 @@ struct mail_keywords *keywords; const char *const *keywords_list; + if ((mail->seq % 100) == 0) { + /* touch the lock file so that if there are tons of + mails another process won't override our lock. */ + (void)file_dotlock_touch(dotlock); + } + keywords_list = mail_get_keywords(mail); keywords = strarray_length(keywords_list) == 0 ? NULL : mailbox_keywords_create(dest_trans, keywords_list); @@ -93,7 +100,8 @@ static int mailbox_convert_list_item(struct mail_storage *source_storage, struct mail_storage *dest_storage, - struct mailbox_list *list) + struct mailbox_list *list, + struct dotlock *dotlock) { struct mailbox *srcbox, *destbox; int ret = 0; @@ -136,7 +144,7 @@ return -1; } - if (mailbox_copy_mails(srcbox, destbox) < 0) { + if (mailbox_copy_mails(srcbox, destbox, dotlock) < 0) { i_error("Mailbox conversion: Couldn't copy mailbox %s", mailbox_get_name(srcbox)); } @@ -147,7 +155,8 @@ } static int mailbox_list_copy(struct mail_storage *source_storage, - struct mail_storage *dest_storage) + struct mail_storage *dest_storage, + struct dotlock *dotlock) { struct mailbox_list_context *iter; struct mailbox_list *list; @@ -157,10 +166,14 @@ MAILBOX_LIST_FAST_FLAGS); while ((list = mail_storage_mailbox_list_next(iter)) != NULL) { if (mailbox_convert_list_item(source_storage, dest_storage, - list) < 0) { + list, dotlock) < 0) { ret = -1; break; } + + /* In case there are lots of mailboxes. Also the other touch + is done only after 100 mails. */ + (void)file_dotlock_touch(dotlock); } if (mail_storage_mailbox_list_deinit(&iter) < 0) ret = -1; @@ -211,7 +224,7 @@ "storage with data: %s", dest_data); ret = -1; } else { - ret = mailbox_list_copy(source_storage, dest_storage); + ret = mailbox_list_copy(source_storage, dest_storage, dotlock); } if (ret == 0) {