[dovecot-cvs] dovecot/src/lib-index mail-cache-transaction.c, 1.21,
1.22
cras at dovecot.org
cras at dovecot.org
Sat Sep 11 12:59:05 EEST 2004
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv5545/lib-index
Modified Files:
mail-cache-transaction.c
Log Message:
Before adding new fields to cache file, make sure they weren't already
added by re-reading the header after file is locked.
Index: mail-cache-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-transaction.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- mail-cache-transaction.c 10 Sep 2004 10:03:08 -0000 1.21
+++ mail-cache-transaction.c 11 Sep 2004 09:59:03 -0000 1.22
@@ -511,8 +511,8 @@
mail_cache_transaction_free(ctx);
}
-static int
-mail_cache_header_write_fields(struct mail_cache_transaction_ctx *ctx)
+static int mail_cache_header_add_field(struct mail_cache_transaction_ctx *ctx,
+ unsigned int field)
{
struct mail_cache *cache = ctx->cache;
buffer_t *buffer;
@@ -524,6 +524,18 @@
if (mail_cache_lock(cache) <= 0)
return -1;
+ /* re-read header to make sure we don't lose any fields. */
+ if (mail_cache_header_fields_read(cache) < 0) {
+ mail_cache_unlock(cache);
+ return -1;
+ }
+
+ if (ctx->cache->field_file_map[field] != (uint32_t)-1) {
+ /* it was already added */
+ mail_cache_unlock(cache);
+ return 0;
+ }
+
t_push();
buffer = buffer_create_dynamic(pool_datastack_create(),
256, (size_t)-1);
@@ -578,7 +590,7 @@
file_field = ctx->cache->field_file_map[field];
if (file_field == (uint32_t)-1) {
/* we'll have to add this field to headers */
- if (mail_cache_header_write_fields(ctx) < 0)
+ if (mail_cache_header_add_field(ctx, field) < 0)
return;
file_field = ctx->cache->field_file_map[field];
More information about the dovecot-cvs
mailing list