[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync.c, 1.41,
1.42
cras at procontrol.fi
cras at procontrol.fi
Sun Jun 20 12:23:17 EEST 2004
- Previous message: [dovecot-cvs] dovecot/src/lib-index mail-cache-lookup.c, 1.2,
1.3 mail-cache-private.h, 1.2, 1.3 mail-cache-transaction.c,
1.2, 1.3 mail-cache.c, 1.28, 1.29 mail-cache.h, 1.9,
1.10 mail-index-private.h, 1.20, 1.21 mail-index-sync-update.c,
1.26, 1.27 mail-index-sync.c, 1.21,
1.22 mail-index-transaction-private.h, 1.4,
1.5 mail-index-transaction.c, 1.11, 1.12 mail-index-view.c,
1.14, 1.15 mail-transaction-log.c, 1.38,
1.39 mail-transaction-log.h, 1.12,
1.13 mail-transaction-util.c, 1.12,
1.13 mail-transaction-util.h, 1.6, 1.7
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-cache.c, 1.29,
1.30 mail-transaction-log.c, 1.39, 1.40
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv7955/lib-storage/index/mbox
Modified Files:
mbox-sync.c
Log Message:
Don't crash if transaction log contains records for messages that don't
exist anymore.
Index: mbox-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- mbox-sync.c 20 Jun 2004 04:18:12 -0000 1.41
+++ mbox-sync.c 20 Jun 2004 09:23:15 -0000 1.42
@@ -258,9 +258,8 @@
mbox_sync_buffer_delete_old(sync_ctx->syncs, uid);
while (uid >= sync_rec->uid1) {
- if (sync_rec->uid1 != 0 &&
+ if (uid <= sync_rec->uid2 &&
sync_rec->type != MAIL_INDEX_SYNC_TYPE_APPEND) {
- i_assert(uid <= sync_rec->uid2);
buffer_append(sync_ctx->syncs, sync_rec,
sizeof(*sync_rec));
@@ -642,23 +641,23 @@
static int
mbox_sync_seek_to_uid(struct mbox_sync_context *sync_ctx, uint32_t uid)
{
- uint32_t seq;
+ uint32_t seq1, seq2;
uint64_t offset;
- if (mail_index_lookup_uid_range(sync_ctx->sync_view, uid, uid,
- &seq, &seq) < 0) {
+ if (mail_index_lookup_uid_range(sync_ctx->sync_view, uid, (uint32_t)-1,
+ &seq1, &seq2) < 0) {
mail_storage_set_index_error(sync_ctx->ibox);
return -1;
}
- if (seq == 0)
+ if (seq1 == 0)
return 0;
- if (mbox_sync_get_from_offset(sync_ctx, seq, &offset) < 0)
+ if (mbox_sync_get_from_offset(sync_ctx, seq1, &offset) < 0)
return -1;
/* set to -1, since they're always increased later */
- sync_ctx->seq = sync_ctx->idx_seq = seq-1;
+ sync_ctx->seq = sync_ctx->idx_seq = seq1-1;
sync_ctx->dest_first_mail = sync_ctx->seq == 0;
if (istream_raw_mbox_seek(sync_ctx->input, offset) < 0) {
mail_storage_set_critical(sync_ctx->ibox->box.storage,
@@ -668,7 +667,7 @@
return -1;
}
(void)istream_raw_mbox_get_body_offset(sync_ctx->input);
- return 0;
+ return 1;
}
static int mbox_sync_loop(struct mbox_sync_context *sync_ctx,
@@ -680,15 +679,9 @@
uoff_t offset;
int ret, expunged;
- if (min_message_count != 0) {
- if (istream_raw_mbox_seek(sync_ctx->input, 0) < 0) {
- /* doesn't begin with a From-line */
- mail_storage_set_error(sync_ctx->ibox->box.storage,
- "Mailbox isn't a valid mbox file");
- return -1;
- }
- sync_ctx->dest_first_mail = TRUE;
- } else {
+ if (min_message_count != 0)
+ ret = 0;
+ else {
/* we sync only what we need to. jump to first record that
needs updating */
const struct mail_index_sync_rec *sync_rec;
@@ -710,10 +703,22 @@
sync_rec = buffer_get_data(sync_ctx->syncs, &size);
if (size == 0)
sync_rec = &sync_ctx->sync_rec;
- if (mbox_sync_seek_to_uid(sync_ctx, sync_rec->uid1) < 0)
+
+ ret = mbox_sync_seek_to_uid(sync_ctx, sync_rec->uid1);
+ if (ret < 0)
return -1;
}
+ if (ret == 0) {
+ if (istream_raw_mbox_seek(sync_ctx->input, 0) < 0) {
+ /* doesn't begin with a From-line */
+ mail_storage_set_error(sync_ctx->ibox->box.storage,
+ "Mailbox isn't a valid mbox file");
+ return -1;
+ }
+ sync_ctx->dest_first_mail = TRUE;
+ }
+
while ((ret = mbox_sync_read_next_mail(sync_ctx, mail_ctx)) > 0) {
uid = mail_ctx->mail.uid;
- Previous message: [dovecot-cvs] dovecot/src/lib-index mail-cache-lookup.c, 1.2,
1.3 mail-cache-private.h, 1.2, 1.3 mail-cache-transaction.c,
1.2, 1.3 mail-cache.c, 1.28, 1.29 mail-cache.h, 1.9,
1.10 mail-index-private.h, 1.20, 1.21 mail-index-sync-update.c,
1.26, 1.27 mail-index-sync.c, 1.21,
1.22 mail-index-transaction-private.h, 1.4,
1.5 mail-index-transaction.c, 1.11, 1.12 mail-index-view.c,
1.14, 1.15 mail-transaction-log.c, 1.38,
1.39 mail-transaction-log.h, 1.12,
1.13 mail-transaction-util.c, 1.12,
1.13 mail-transaction-util.h, 1.6, 1.7
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-cache.c, 1.29,
1.30 mail-transaction-log.c, 1.39, 1.40
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list