[dovecot-cvs] dovecot/src/lib-index mail-cache-transaction.c, 1.49.2.1, 1.49.2.2
tss at dovecot.org
tss at dovecot.org
Thu Feb 1 22:23:50 UTC 2007
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv4258
Modified Files:
Tag: branch_1_0
mail-cache-transaction.c
Log Message:
If cache file wasn't opened yet when flushing a transaction, the changes
weren't written to the file. Also fixes a "invalid record size" bug which
could have happened when transaction flush failed.
Index: mail-cache-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-transaction.c,v
retrieving revision 1.49.2.1
retrieving revision 1.49.2.2
diff -u -d -r1.49.2.1 -r1.49.2.2
--- mail-cache-transaction.c 15 Oct 2006 15:11:33 -0000 1.49.2.1
+++ mail-cache-transaction.c 1 Feb 2007 22:23:15 -0000 1.49.2.2
@@ -468,6 +468,11 @@
buffer_set_used_size(ctx->cache_data, ctx->prev_pos);
}
+ if (ctx->cache_file_seq == 0) {
+ if ((ret = mail_cache_transaction_lock(ctx)) <= 0)
+ return ret;
+ }
+
if (ctx->cache_file_seq != ctx->cache->hdr->file_seq) {
/* cache file reopened - need to abort */
mail_cache_transaction_reset(ctx);
@@ -487,7 +492,7 @@
max_size, &write_offset,
&max_size, commit);
if (ret <= 0) {
- /* nothing to write / error / cache file reopened */
+ /* error / couldn't lock / cache file reopened */
return ret;
}
@@ -544,7 +549,7 @@
data = buffer_get_modifyable_data(ctx->cache_data, &size);
rec = PTR_OFFSET(data, ctx->prev_pos);
rec->size = size - ctx->prev_pos;
- i_assert(rec->size != 0);
+ i_assert(rec->size > sizeof(*rec));
array_append(&ctx->cache_data_seq, &ctx->prev_seq, 1);
ctx->prev_pos = size;
@@ -736,8 +741,13 @@
cache file had been compressed and was reopened, return
without adding the cached data since cache_data buffer
doesn't contain the cache_rec anymore. */
- if (mail_cache_transaction_flush(ctx) <= 0)
+ if (mail_cache_transaction_flush(ctx) <= 0) {
+ /* make sure the transaction is reset, so we don't
+ constantly try to flush for each call to this
+ function */
+ mail_cache_transaction_reset(ctx);
return;
+ }
}
buffer_append(ctx->cache_data, &file_field, sizeof(file_field));
More information about the dovecot-cvs
mailing list