[dovecot-cvs] dovecot: Don't assume that transaction record type is a bitmask ...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Jun 13 22:13:54 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/ad695be143ff
changeset: 5723:ad695be143ff
user: Timo Sirainen <tss at iki.fi>
date: Wed Jun 13 22:11:43 2007 +0300
description:
Don't assume that transaction record type is a bitmask in the transaction
log file, even though it's internally used as such.
diffstat:
3 files changed, 20 insertions(+), 21 deletions(-)
src/lib-index/mail-index-sync-update.c | 3 +-
src/lib-index/mail-transaction-log-file.c | 3 +-
src/lib-index/mail-transaction-log-view.c | 35 +++++++++++++----------------
diffs (109 lines):
diff -r 9c53047d3b2c -r ad695be143ff src/lib-index/mail-index-sync-update.c
--- a/src/lib-index/mail-index-sync-update.c Wed Jun 13 21:51:15 2007 +0300
+++ b/src/lib-index/mail-index-sync-update.c Wed Jun 13 22:11:43 2007 +0300
@@ -860,7 +860,8 @@ int mail_index_sync_map(struct mail_inde
prev_offset <
view->map->hdr.log_file_index_ext_offset))
continue;
- } else if ((thdr->type & MAIL_TRANSACTION_EXPUNGE) != 0) {
+ } else if ((thdr->type & MAIL_TRANSACTION_TYPE_MASK) ==
+ MAIL_TRANSACTION_EXPUNGE) {
/* if the message hasn't yet been expunged from the
mailbox, skip this expunge */
if (prev_seq > mailbox_sync_seq ||
diff -r 9c53047d3b2c -r ad695be143ff src/lib-index/mail-transaction-log-file.c
--- a/src/lib-index/mail-transaction-log-file.c Wed Jun 13 21:51:15 2007 +0300
+++ b/src/lib-index/mail-transaction-log-file.c Wed Jun 13 22:11:43 2007 +0300
@@ -668,7 +668,8 @@ log_file_track_mailbox_sync_offset(struc
i_assert((hdr->type & MAIL_TRANSACTION_EXTERNAL) != 0);
- if ((hdr->type & MAIL_TRANSACTION_HEADER_UPDATE) != 0) {
+ if ((hdr->type & MAIL_TRANSACTION_TYPE_MASK) ==
+ MAIL_TRANSACTION_HEADER_UPDATE) {
/* see if this updates mailbox_sync_offset */
ret = log_file_track_mailbox_sync_offset_hdr(file, hdr + 1,
trans_size -
diff -r 9c53047d3b2c -r ad695be143ff src/lib-index/mail-transaction-log-view.c
--- a/src/lib-index/mail-transaction-log-view.c Wed Jun 13 21:51:15 2007 +0300
+++ b/src/lib-index/mail-transaction-log-view.c Wed Jun 13 22:11:43 2007 +0300
@@ -323,8 +323,7 @@ static bool
static bool
log_view_is_record_valid(struct mail_transaction_log_file *file,
const struct mail_transaction_header *hdr,
- const void *data,
- const struct mail_transaction_type_map *type_rec)
+ const void *data)
{
enum mail_transaction_type rec_type;
ARRAY_TYPE(seq_range) uids = ARRAY_INIT;
@@ -343,10 +342,6 @@ log_view_is_record_valid(struct mail_tra
"expunge record missing protection mask");
return FALSE;
}
- } else if (rec_type != type_rec->type) {
- mail_transaction_log_file_set_corrupted(file,
- "extra bits in header type: 0x%x", rec_type);
- return FALSE;
}
if (rec_size == 0) {
@@ -542,7 +537,7 @@ log_view_get_next(struct mail_transactio
return -1;
}
- if (!log_view_is_record_valid(file, hdr, data, type_rec))
+ if (!log_view_is_record_valid(file, hdr, data))
return -1;
*hdr_r = hdr;
@@ -557,6 +552,7 @@ int mail_transaction_log_view_next(struc
{
const struct mail_transaction_header *hdr;
const void *data;
+ uint32_t hdr_type = 0;
int ret = 0;
if (skipped_r != NULL)
@@ -565,12 +561,16 @@ int mail_transaction_log_view_next(struc
return -1;
while ((ret = log_view_get_next(view, &hdr, &data)) > 0) {
- if ((view->type_mask & hdr->type) != 0) {
- /* looks like this is within our mask, but expunge
- protection may mess up the check. */
- if ((hdr->type & MAIL_TRANSACTION_EXPUNGE) == 0 ||
- (view->type_mask & MAIL_TRANSACTION_EXPUNGE) != 0)
- break;
+ /* drop expunge protection */
+ if ((hdr->type & MAIL_TRANSACTION_TYPE_MASK) ==
+ (MAIL_TRANSACTION_EXPUNGE | MAIL_TRANSACTION_EXPUNGE_PROT))
+ hdr_type = hdr->type & ~MAIL_TRANSACTION_EXPUNGE_PROT;
+ else
+ hdr_type = hdr->type;
+
+ if ((view->type_mask & hdr_type) != 0) {
+ /* the record is within our wanted mask */
+ break;
}
/* we don't want this record */
@@ -588,15 +588,12 @@ int mail_transaction_log_view_next(struc
if (ret == 0)
return 0;
- view->tmp_hdr = *hdr;
+ /* return type without expunge protection */
+ view->tmp_hdr.type = hdr_type;
+ /* return record's size */
view->tmp_hdr.size =
mail_index_offset_to_uint32(view->tmp_hdr.size) - sizeof(*hdr);
i_assert(view->tmp_hdr.size != 0);
-
- if ((hdr->type & MAIL_TRANSACTION_EXPUNGE) != 0) {
- /* hide expunge protection */
- view->tmp_hdr.type &= ~MAIL_TRANSACTION_EXPUNGE_PROT;
- }
*hdr_r = &view->tmp_hdr;
*data_r = data;
More information about the dovecot-cvs
mailing list