[dovecot-cvs]
dovecot/src/lib-storage/index/mbox istream-raw-mbox.c, 1.7,
1.8 mbox-mail.c, 1.3, 1.4 mbox-sync-rewrite.c, 1.12,
1.13 mbox-sync.c, 1.20, 1.21
cras at procontrol.fi
cras at procontrol.fi
Tue Jun 15 02:35:20 EEST 2004
- Previous message: [dovecot-cvs]
dovecot/src/lib-storage/index/mbox istream-raw-mbox.c, 1.6,
1.7 istream-raw-mbox.h, 1.3, 1.4 mbox-lock.c, 1.3,
1.4 mbox-sync-parse.c, 1.10, 1.11 mbox-sync-private.h, 1.10,
1.11 mbox-sync-update.c, 1.9, 1.10 mbox-sync.c, 1.19, 1.20
- Next message: [dovecot-cvs] dovecot/src/lib fdpass.c,1.28,1.29
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv11018/lib-storage/index/mbox
Modified Files:
istream-raw-mbox.c mbox-mail.c mbox-sync-rewrite.c mbox-sync.c
Log Message:
more syncing fixes
Index: istream-raw-mbox.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/istream-raw-mbox.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- istream-raw-mbox.c 14 Jun 2004 22:44:56 -0000 1.7
+++ istream-raw-mbox.c 14 Jun 2004 23:35:17 -0000 1.8
@@ -140,21 +140,22 @@
i = 0;
if (pos >= 31) {
- if (memcmp(buf, "\nFrom ", 6) == 0 &&
- mbox_from_parse(buf+6, pos-6,
- &received_time, &sender) == 0) {
- rstream->next_received_time = received_time;
- rstream->mail_size = stream->istream.v_offset -
- rstream->hdr_offset;
+ if (memcmp(buf, "\nFrom ", 6) == 0) {
+ if (mbox_from_parse(buf+6, pos-6,
+ &received_time, &sender) == 0) {
+ rstream->next_received_time = received_time;
+ rstream->mail_size = stream->istream.v_offset -
+ rstream->hdr_offset;
- i_free(rstream->next_sender);
- rstream->next_sender = sender;
- i_assert(stream->pos == 0);
- return -1;
- }
+ i_free(rstream->next_sender);
+ rstream->next_sender = sender;
+ i_assert(stream->pos == 0);
+ return -1;
+ }
- /* we don't want to get stuck at invalid From-line */
- i += 6;
+ /* we don't want to get stuck at invalid From-line */
+ i += 6;
+ }
} else if (ret == -1) {
/* last few bytes, can't contain From-line */
if (buf[pos-1] == '\n') {
@@ -162,6 +163,19 @@
pos--;
}
+ if (rstream->body_offset == (uoff_t)-1) {
+ /* find body_offset */
+ for (; i < pos; i++) {
+ if (buf[i] == '\n' && i > 0 &&
+ buf[i-1] == '\n') {
+ rstream->body_offset =
+ stream->istream.v_offset +
+ i + 1;
+ break;
+ }
+ }
+ }
+
ret = pos <= stream->pos ? -1 :
(ssize_t) (pos - stream->pos);
Index: mbox-mail.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-mail.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- mbox-mail.c 14 Jun 2004 04:30:32 -0000 1.3
+++ mbox-mail.c 14 Jun 2004 23:35:17 -0000 1.4
@@ -91,6 +91,7 @@
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail_data *data = &mail->data;
struct istream *raw_stream;
+ uoff_t offset;
if (data->stream == NULL) {
if (mbox_mail_seek(mail) < 0)
@@ -98,11 +99,9 @@
// FIXME: need to hide the headers
raw_stream = mail->ibox->mbox_stream;
- (void)i_stream_read(raw_stream); /* fix v_offset */
- data->stream = i_stream_create_limit(default_pool,
- raw_stream,
- raw_stream->v_offset,
- (uoff_t)-1);
+ offset = istream_raw_mbox_get_header_offset(raw_stream);
+ data->stream = i_stream_create_limit(default_pool, raw_stream,
+ offset, (uoff_t)-1);
}
return index_mail_init_stream(mail, hdr_size, body_size);
Index: mbox-sync-rewrite.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-rewrite.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mbox-sync-rewrite.c 14 Jun 2004 19:23:25 -0000 1.12
+++ mbox-sync-rewrite.c 14 Jun 2004 23:35:17 -0000 1.13
@@ -174,7 +174,11 @@
}
}
- i_assert(ctx->header_first_change != (size_t)-1 || move_diff != 0);
+ if (ctx->header_first_change == (size_t)-1 && move_diff == 0) {
+ /* no changes actually. we get here if index sync record told
+ us to do something that was already there */
+ return 1;
+ }
if (move_diff != 0) {
/* we're moving the header, forget about partial write
Index: mbox-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- mbox-sync.c 14 Jun 2004 22:44:56 -0000 1.20
+++ mbox-sync.c 14 Jun 2004 23:35:17 -0000 1.21
@@ -248,8 +248,11 @@
sync = buffer_get_data(syncs_buf, &size);
size /= sizeof(*sync);
- for (i = 0; i < size; i++)
+ for (i = 0; i < size; i++) {
+ if (sync[i].type != MAIL_INDEX_SYNC_TYPE_FLAGS)
+ continue;
mail_index_sync_flags_apply(&sync[i], flags, keywords);
+ }
}
static int
@@ -600,9 +603,20 @@
/* set to -1, since they're always increased later */
sync_ctx->seq = sync_ctx->idx_seq = seq-1;
istream_raw_mbox_seek(sync_ctx->input, offset);
+ (void)istream_raw_mbox_get_body_offset(sync_ctx->input);
return 0;
}
+static void mbox_sync_fake_headers(struct mbox_sync_context *sync_ctx)
+{
+ /* we didn't go through everything. fake the headers and all */
+ i_assert(sync_ctx->next_uid <= sync_ctx->hdr->next_uid);
+
+ sync_ctx->next_uid = sync_ctx->hdr->next_uid;
+ sync_ctx->base_uid_last = sync_ctx->hdr->next_uid-1;
+ sync_ctx->base_uid_validity = sync_ctx->hdr->uid_validity;
+}
+
static int mbox_sync_loop(struct mbox_sync_context *sync_ctx,
struct mbox_sync_mail_context *mail_ctx,
uint32_t min_message_count)
@@ -625,6 +639,7 @@
if (sync_ctx->sync_rec.uid1 == 0) {
/* nothing to do */
+ mbox_sync_fake_headers(sync_ctx);
return 0;
}
@@ -709,11 +724,7 @@
while (sync_ctx->idx_seq < messages_count)
mail_index_expunge(sync_ctx->t, ++sync_ctx->idx_seq);
} else {
- /* we didn't go through everything. fake the headers and all */
- i_assert(sync_ctx->next_uid <= sync_ctx->hdr->next_uid);
- sync_ctx->next_uid = sync_ctx->hdr->next_uid;
- sync_ctx->base_uid_last = sync_ctx->hdr->next_uid-1;
- sync_ctx->base_uid_validity = sync_ctx->hdr->uid_validity;
+ mbox_sync_fake_headers(sync_ctx);
}
return 0;
@@ -790,6 +801,7 @@
return -1;
}
+ sync_ctx->expunged_space = 0;
istream_raw_mbox_flush(sync_ctx->input);
}
return 0;
@@ -888,6 +900,16 @@
if (mbox_sync_handle_eof_updates(sync_ctx, &mail_ctx) < 0)
return -1;
+ /* only syncs left should be just appends (and their updates)
+ which weren't synced yet for some reason (crash). we'll just
+ ignore them, as we've overwritten them above. */
+ while (mail_index_sync_next(sync_ctx->index_sync_ctx,
+ &sync_ctx->sync_rec) > 0)
+ ;
+
+ buffer_set_used_size(sync_ctx->syncs, 0);
+ memset(&sync_ctx->sync_rec, 0, sizeof(sync_ctx->sync_rec));
+
if (sync_ctx->base_uid_last != sync_ctx->next_uid-1) {
/* rewrite X-IMAPbase header */
if (mbox_sync_check_excl_lock(sync_ctx) == -1)
@@ -902,13 +924,6 @@
return -1;
}
- /* only syncs left should be just appends (and their updates)
- which weren't synced yet for some reason (crash). we'll just
- ignore them, as we've overwritten them above. */
- while (mail_index_sync_next(sync_ctx->index_sync_ctx,
- &sync_ctx->sync_rec) > 0)
- ;
-
if (mbox_sync_update_index_header(sync_ctx) < 0)
return -1;
- Previous message: [dovecot-cvs]
dovecot/src/lib-storage/index/mbox istream-raw-mbox.c, 1.6,
1.7 istream-raw-mbox.h, 1.3, 1.4 mbox-lock.c, 1.3,
1.4 mbox-sync-parse.c, 1.10, 1.11 mbox-sync-private.h, 1.10,
1.11 mbox-sync-update.c, 1.9, 1.10 mbox-sync.c, 1.19, 1.20
- Next message: [dovecot-cvs] dovecot/src/lib fdpass.c,1.28,1.29
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list