dovecot-2.0: Fixed bugs caused by recent mail-transaction-log-ap...
dovecot at dovecot.org
dovecot at dovecot.org
Wed May 27 03:23:34 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/50b879627fb1
changeset: 9393:50b879627fb1
user: Timo Sirainen <tss at iki.fi>
date: Tue May 26 20:21:18 2009 -0400
description:
Fixed bugs caused by recent mail-transaction-log-append refactoring.
diffstat:
1 file changed, 14 insertions(+), 15 deletions(-)
src/lib-index/mail-transaction-log-append.c | 29 +++++++++++++--------------
diffs (87 lines):
diff -r 75a8a2a8103f -r 50b879627fb1 src/lib-index/mail-transaction-log-append.c
--- a/src/lib-index/mail-transaction-log-append.c Tue May 26 16:51:58 2009 -0400
+++ b/src/lib-index/mail-transaction-log-append.c Tue May 26 20:21:18 2009 -0400
@@ -30,9 +30,8 @@ void mail_transaction_log_append_add(str
buffer_append(ctx->output, &hdr, sizeof(hdr));
buffer_append(ctx->output, data, size);
- if (mail_transaction_header_has_modseq(data,
- CONST_PTR_OFFSET(data, sizeof(hdr)),
- ctx->new_highest_modseq))
+ if (mail_transaction_header_has_modseq(&hdr, data,
+ ctx->new_highest_modseq))
ctx->new_highest_modseq++;
}
@@ -44,17 +43,16 @@ log_buffer_move_to_memory(struct mail_tr
/* first we need to truncate this latest write so that log syncing
doesn't break */
if (ftruncate(file->fd, file->sync_offset) < 0) {
- mail_index_file_set_syscall_error(file->log->index,
+ mail_index_file_set_syscall_error(ctx->log->index,
file->filepath,
"ftruncate()");
}
- if (mail_index_move_to_memory(file->log->index) < 0)
+ if (mail_index_move_to_memory(ctx->log->index) < 0)
return -1;
i_assert(MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file));
- i_assert(file->buffer_offset + file->buffer->used ==
- file->sync_offset);
+ i_assert(file->buffer_offset + file->buffer->used == file->sync_offset);
buffer_append_buf(file->buffer, ctx->output, 0, (size_t)-1);
file->sync_offset = file->buffer_offset + file->buffer->used;
return 0;
@@ -65,6 +63,9 @@ static int log_buffer_write(struct mail_
struct mail_transaction_log_file *file = ctx->log->head;
struct mail_transaction_header *hdr;
uint32_t first_size;
+
+ if (ctx->output->used == 0)
+ return 0;
if (MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file)) {
if (file->buffer == NULL) {
@@ -86,7 +87,7 @@ static int log_buffer_write(struct mail_
file->sync_offset) < 0) {
/* write failure, fallback to in-memory indexes. */
hdr->size = first_size;
- mail_index_file_set_syscall_error(file->log->index,
+ mail_index_file_set_syscall_error(ctx->log->index,
file->filepath,
"pwrite_full()");
return log_buffer_move_to_memory(ctx);
@@ -101,16 +102,16 @@ static int log_buffer_write(struct mail_
if (pwrite_full(file->fd, &first_size, sizeof(uint32_t),
file->sync_offset +
offsetof(struct mail_transaction_header, size)) < 0) {
- mail_index_file_set_syscall_error(file->log->index,
+ mail_index_file_set_syscall_error(ctx->log->index,
file->filepath,
"pwrite_full()");
return log_buffer_move_to_memory(ctx);
}
- if ((ctx->want_fsync && !file->log->index->fsync_disable) ||
- file->log->index->nfs_flush) {
+ if ((ctx->want_fsync && !ctx->log->index->fsync_disable) ||
+ ctx->log->index->nfs_flush) {
if (fdatasync(file->fd) < 0) {
- mail_index_file_set_syscall_error(file->log->index,
+ mail_index_file_set_syscall_error(ctx->log->index,
file->filepath,
"fdatasync()");
return log_buffer_move_to_memory(ctx);
@@ -215,9 +216,7 @@ int mail_transaction_log_append_commit(s
*_ctx = NULL;
- if (ctx->output->used > 0)
- ret = mail_transaction_log_append_locked(ctx);
-
+ ret = mail_transaction_log_append_locked(ctx);
if (!index->log_locked)
mail_transaction_log_file_unlock(index->log->head);
More information about the dovecot-cvs
mailing list