From: Timo Sirainen Date: Wed, 18 Jun 2008 05:08:45 +0000 (+0300) Subject: Mail index extension introductions now add a "no resizes" flag to the X-Git-Tag: 1.2.alpha1~266 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=838f56174b963779a88083a0d0e85b30d2d846e7;p=thirdparty%2Fdovecot%2Fcore.git Mail index extension introductions now add a "no resizes" flag to the intro records. If it's found, the header and record sizes are used only if the extension doesn't exist yet, otherwise they're ignored. --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-index-sync-ext.c b/src/lib-index/mail-index-sync-ext.c index dce1e702c6..a75dfa9050 100644 --- a/src/lib-index/mail-index-sync-ext.c +++ b/src/lib-index/mail-index-sync-ext.c @@ -446,6 +446,7 @@ int mail_index_sync_ext_intro(struct mail_index_sync_map_ctx *ctx, const struct mail_index_ext *ext; const char *name, *error; uint32_t ext_map_idx; + bool no_resize; /* default to ignoring the following extension updates in case this intro is corrupted */ @@ -496,6 +497,7 @@ int mail_index_sync_ext_intro(struct mail_index_sync_map_ctx *ctx, ext_hdr.hdr_size = u->hdr_size; ext_hdr.record_size = u->record_size; ext_hdr.record_align = u->record_align; + no_resize = (u->flags & MAIL_TRANSACTION_EXT_INTRO_FLAG_NO_RESIZE) != 0; /* make sure the header looks valid before doing anything with it */ if (mail_index_map_ext_hdr_check(&map->hdr, &ext_hdr, @@ -509,7 +511,8 @@ int mail_index_sync_ext_intro(struct mail_index_sync_map_ctx *ctx, /* exists already */ if (u->reset_id == ext->reset_id) { /* check if we need to resize anything */ - sync_ext_resize(u, ext_map_idx, ctx); + if (!no_resize) + sync_ext_resize(u, ext_map_idx, ctx); ctx->cur_ext_ignore = FALSE; } else { /* extension was reset and this transaction hadn't diff --git a/src/lib-index/mail-transaction-log-append.c b/src/lib-index/mail-transaction-log-append.c index 85c4d492a7..ced0c4dd1f 100644 --- a/src/lib-index/mail-transaction-log-append.c +++ b/src/lib-index/mail-transaction-log-append.c @@ -264,6 +264,7 @@ static void log_append_ext_intro(struct log_append_context *ctx, intro->hdr_size = rext->hdr_size; intro->record_size = rext->record_size; intro->record_align = rext->record_align; + intro->flags = MAIL_TRANSACTION_EXT_INTRO_FLAG_NO_RESIZE; intro->name_size = idx != (uint32_t)-1 ? 0 : strlen(rext->name); } diff --git a/src/lib-index/mail-transaction-log.h b/src/lib-index/mail-transaction-log.h index a8df86673b..25e0dc2a4a 100644 --- a/src/lib-index/mail-transaction-log.h +++ b/src/lib-index/mail-transaction-log.h @@ -84,6 +84,11 @@ struct mail_transaction_header_update { /* unsigned char data[]; */ }; +enum { + /* Ignore hdr_size, record_size and record_align */ + MAIL_TRANSACTION_EXT_INTRO_FLAG_NO_RESIZE = 0x01 +}; + struct mail_transaction_ext_intro { /* old extension: set ext_id. don't set name. new extension: ext_id = (uint32_t)-1. give name. */ @@ -92,7 +97,7 @@ struct mail_transaction_ext_intro { uint32_t hdr_size; uint16_t record_size; uint16_t record_align; - uint16_t unused_padding; + uint16_t flags; uint16_t name_size; /* unsigned char name[]; */ };