dovecot: Keep transaction logs referenced while we know we need ...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Sep 22 15:14:25 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/cca479cb3ef0
changeset: 6458:cca479cb3ef0
user: Timo Sirainen <tss at iki.fi>
date: Sat Sep 22 15:14:20 2007 +0300
description:
Keep transaction logs referenced while we know we need them. This fixes
desync errors with in-memory indexes.
diffstat:
4 files changed, 25 insertions(+), 8 deletions(-)
src/lib-index/mail-index-view-sync.c | 6 ++++--
src/lib-index/mail-transaction-log-view.c | 12 ++++++++++--
src/lib-index/mail-transaction-log.c | 9 +++++++--
src/lib-index/mail-transaction-log.h | 6 ++++--
diffs (85 lines):
diff -r 3645048f6f6e -r cca479cb3ef0 src/lib-index/mail-index-view-sync.c
--- 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 @@ view_sync_set_log_view_range(struct mail
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 @@ int mail_index_view_sync_commit(struct m
#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);
diff -r 3645048f6f6e -r cca479cb3ef0 src/lib-index/mail-transaction-log-view.c
--- 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 @@ int mail_transaction_log_view_set(struct
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;
diff -r 3645048f6f6e -r cca479cb3ef0 src/lib-index/mail-transaction-log.c
--- 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 @@ void mail_transaction_logs_clean(struct
{
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);
}
diff -r 3645048f6f6e -r cca479cb3ef0 src/lib-index/mail-transaction-log.h
--- 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 @@ int mail_transaction_log_view_set(struct
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. */
More information about the dovecot-cvs
mailing list