Mercurial > dovecot > core-2.2
changeset 6458:cca479cb3ef0 HEAD
Keep transaction logs referenced while we know we need them. This fixes
desync errors with in-memory indexes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 22 Sep 2007 15:14:20 +0300 |
parents | 3645048f6f6e |
children | c6849b4a3812 |
files | src/lib-index/mail-index-view-sync.c src/lib-index/mail-transaction-log-view.c src/lib-index/mail-transaction-log.c src/lib-index/mail-transaction-log.h |
diffstat | 4 files changed, 24 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-view-sync.c Sat Sep 22 14:28:01 2007 +0300 +++ b/src/lib-index/mail-index-view-sync.c Sat Sep 22 15:14:20 2007 +0300 @@ -132,7 +132,8 @@ end_seq--; end_offset = (uoff_t)-1; if (end_seq < start_seq) { /* we have only this reset log */ - mail_transaction_log_view_clear(view->log_view); + mail_transaction_log_view_clear(view->log_view, + view->log_file_expunge_seq); break; } } @@ -657,7 +658,8 @@ #endif /* set log view to empty range so unneeded memory gets freed */ - mail_transaction_log_view_clear(view->log_view); + mail_transaction_log_view_clear(view->log_view, + view->log_file_expunge_seq); if (array_is_created(&ctx->expunges)) array_free(&ctx->expunges);
--- a/src/lib-index/mail-transaction-log-view.c Sat Sep 22 14:28:01 2007 +0300 +++ b/src/lib-index/mail-transaction-log-view.c Sat Sep 22 15:14:20 2007 +0300 @@ -278,9 +278,17 @@ return 1; } -void mail_transaction_log_view_clear(struct mail_transaction_log_view *view) +void mail_transaction_log_view_clear(struct mail_transaction_log_view *view, + uint32_t oldest_file_seq) { + struct mail_transaction_log_file *file; + mail_transaction_log_view_unref_all(view); + if (mail_transaction_log_find_file(view->log, oldest_file_seq, + &file) > 0) { + array_append(&view->file_refs, &file, 1); + file->refcount++; + } view->cur = view->head = view->tail = NULL;
--- a/src/lib-index/mail-transaction-log.c Sat Sep 22 14:28:01 2007 +0300 +++ b/src/lib-index/mail-transaction-log.c Sat Sep 22 15:14:20 2007 +0300 @@ -188,12 +188,17 @@ { struct mail_transaction_log_file *file, *next; + /* remove only files from the beginning. this way if a view has + referenced an old file, it can still find the new files even if + there aren't any references to it currently. */ for (file = log->files; file != NULL; file = next) { next = file->next; i_assert(file->refcount >= 0); - if (file->refcount == 0) - mail_transaction_log_file_free(&file); + if (file->refcount > 0) + break; + + mail_transaction_log_file_free(&file); } i_assert(log->head == NULL || log->files != NULL); }
--- a/src/lib-index/mail-transaction-log.h Sat Sep 22 14:28:01 2007 +0300 +++ b/src/lib-index/mail-transaction-log.h Sat Sep 22 15:14:20 2007 +0300 @@ -153,8 +153,10 @@ uint32_t min_file_seq, uoff_t min_file_offset, uint32_t max_file_seq, uoff_t max_file_offset, bool *reset_r); -/* Clear the view. */ -void mail_transaction_log_view_clear(struct mail_transaction_log_view *view); +/* Clear the view. Keep oldest_file_seq log referenced so we don't get + desynced. */ +void mail_transaction_log_view_clear(struct mail_transaction_log_view *view, + uint32_t oldest_file_seq); /* Read next transaction record from current position. The position is updated. Returns -1 if error, 0 if we're at end of the view, 1 if ok. */