[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync-parse.c,
1.14, 1.15 mbox-sync-private.h, 1.18, 1.19 mbox-sync-rewrite.c,
1.20, 1.21 mbox-sync.c, 1.46, 1.47
cras at procontrol.fi
cras at procontrol.fi
Sun Jun 20 16:48:37 EEST 2004
Update of /home/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv13163/lib-storage/index/mbox
Modified Files:
mbox-sync-parse.c mbox-sync-private.h mbox-sync-rewrite.c
mbox-sync.c
Log Message:
fixes for From-line offset updating
Index: mbox-sync-parse.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-parse.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- mbox-sync-parse.c 20 Jun 2004 13:03:02 -0000 1.14
+++ mbox-sync-parse.c 20 Jun 2004 13:48:34 -0000 1.15
@@ -274,8 +274,7 @@
}
void mbox_sync_parse_next_mail(struct istream *input,
- struct mbox_sync_mail_context *ctx,
- int rewriting)
+ struct mbox_sync_mail_context *ctx)
{
struct mbox_sync_context *sync_ctx = ctx->sync_ctx;
struct message_header_parser_ctx *hdr_ctx;
Index: mbox-sync-private.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-private.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- mbox-sync-private.h 20 Jun 2004 13:03:02 -0000 1.18
+++ mbox-sync-private.h 20 Jun 2004 13:48:34 -0000 1.19
@@ -91,7 +91,7 @@
struct mail_index_sync_rec sync_rec;
uint32_t prev_msg_uid, next_uid;
- uint32_t seq, idx_seq, need_space_seq;
+ uint32_t seq, idx_seq, need_space_seq, need_space_idx_seq;
off_t expunged_space, space_diff;
unsigned int dest_first_mail:1;
@@ -103,8 +103,7 @@
int mbox_sync_has_changed(struct index_mailbox *ibox);
void mbox_sync_parse_next_mail(struct istream *input,
- struct mbox_sync_mail_context *ctx,
- int rewriting);
+ struct mbox_sync_mail_context *ctx);
void mbox_sync_update_header(struct mbox_sync_mail_context *ctx,
buffer_t *syncs_buf);
void mbox_sync_update_header_from(struct mbox_sync_mail_context *ctx,
Index: mbox-sync-rewrite.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-rewrite.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- mbox-sync-rewrite.c 20 Jun 2004 03:25:34 -0000 1.20
+++ mbox-sync-rewrite.c 20 Jun 2004 13:48:34 -0000 1.21
@@ -301,7 +301,7 @@
sync_ctx->prev_msg_uid = mails[idx].uid-1;
sync_ctx->dest_first_mail = mails[idx].from_offset == 0;
- mbox_sync_parse_next_mail(sync_ctx->input, &mail_ctx, TRUE);
+ mbox_sync_parse_next_mail(sync_ctx->input, &mail_ctx);
if (mails[idx].space != 0)
mbox_sync_update_header_from(&mail_ctx, &mails[idx]);
else {
Index: mbox-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- mbox-sync.c 20 Jun 2004 13:29:01 -0000 1.46
+++ mbox-sync.c 20 Jun 2004 13:48:34 -0000 1.47
@@ -212,7 +212,7 @@
mail_ctx->from_offset++;
}
- mbox_sync_parse_next_mail(sync_ctx->input, mail_ctx, FALSE);
+ mbox_sync_parse_next_mail(sync_ctx->input, mail_ctx);
i_assert(sync_ctx->input->v_offset != mail_ctx->from_offset);
mail_ctx->mail.body_size =
@@ -478,25 +478,30 @@
return 0;
}
-static void
-update_from_offsets(struct index_mailbox *ibox,
- struct mail_index_transaction *t, buffer_t *mails_buf,
- uint32_t seq1, uint32_t seq2)
+static void update_from_offsets(struct mbox_sync_context *sync_ctx)
{
const struct mbox_sync_mail *mails;
- uint32_t extra_idx = ibox->mbox_extra_idx;
+ uint32_t idx, idx_seq, extra_idx = sync_ctx->ibox->mbox_extra_idx;
uint64_t offset;
size_t size;
- mails = buffer_get_modifyable_data(mails_buf, &size);
- i_assert((seq2-seq1+1) * sizeof(*mails) == size);
+ mails = buffer_get_modifyable_data(sync_ctx->mails, &size);
+ size /= sizeof(*mails);
+ i_assert(sync_ctx->need_space_seq - sync_ctx->seq + 1 == size);
- for (; seq1 <= seq2; seq1++, mails++) {
- if (mails->uid != 0) {
- offset = mails->from_offset;
- mail_index_update_extra_rec(t, seq1, extra_idx,
- &offset);
- }
+ idx = 0;
+ idx_seq = sync_ctx->need_space_idx_seq;
+ if (idx_seq == 0) {
+ idx++; idx_seq++;
+ }
+
+ for (; idx < size; idx++, idx_seq++, mails++) {
+ if (mails->uid == 0)
+ continue;
+
+ offset = mails->from_offset;
+ mail_index_update_extra_rec(sync_ctx->t, idx_seq, extra_idx,
+ &offset);
}
}
@@ -586,6 +591,7 @@
if (ret == 0 && sync_ctx->need_space_seq == 0) {
/* first mail with no space to write it */
sync_ctx->need_space_seq = sync_ctx->seq;
+ sync_ctx->need_space_idx_seq = sync_ctx->idx_seq;
sync_ctx->space_diff = 0;
if (sync_ctx->expunged_space > 0) {
@@ -633,8 +639,7 @@
sync_ctx->need_space_seq, sync_ctx->seq) < 0)
return -1;
- update_from_offsets(sync_ctx->ibox, sync_ctx->t, sync_ctx->mails,
- sync_ctx->need_space_seq, sync_ctx->seq);
+ update_from_offsets(sync_ctx);
/* mail_ctx may contain wrong data after rewrite, so make sure we
don't try to access it */
@@ -870,9 +875,7 @@
return -1;
}
- update_from_offsets(sync_ctx->ibox, sync_ctx->t,
- sync_ctx->mails,
- sync_ctx->need_space_seq, sync_ctx->seq);
+ update_from_offsets(sync_ctx);
sync_ctx->need_space_seq = 0;
buffer_set_used_size(sync_ctx->mails, 0);
More information about the dovecot-cvs
mailing list