[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-mail.c, 1.10,
1.11 dbox-sync-full.c, 1.5, 1.6 dbox-uidlist.c, 1.29, 1.30
cras at dovecot.org
cras at dovecot.org
Thu Jun 8 20:14:03 EEST 2006
Update of /var/lib/cvs/dovecot/src/lib-storage/index/dbox
In directory talvi:/tmp/cvs-serv24654
Modified Files:
dbox-mail.c dbox-sync-full.c dbox-uidlist.c
Log Message:
Several dbox fixes backported from branch_1_0
Index: dbox-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-mail.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- dbox-mail.c 16 May 2006 09:10:33 -0000 1.10
+++ dbox-mail.c 8 Jun 2006 17:14:00 -0000 1.11
@@ -72,52 +72,69 @@
}
}
-static int dbox_mail_open(struct index_mail *mail, uoff_t *offset_r)
+static bool dbox_mail_try_open(struct index_mail *mail,
+ uint32_t *file_seq_r, uoff_t *offset_r,
+ int *ret_r)
{
struct dbox_mailbox *mbox = (struct dbox_mailbox *)mail->ibox;
uint32_t seq = mail->mail.mail.seq;
+
+ *ret_r = dbox_mail_lookup_offset(mail->trans, seq,
+ file_seq_r, offset_r);
+ if (*ret_r <= 0) {
+ if (*ret_r == 0)
+ mail->mail.mail.expunged = TRUE;
+ return TRUE;
+ }
+
+ if ((*ret_r = dbox_file_seek(mbox, *file_seq_r, *offset_r)) < 0)
+ return TRUE;
+ if (*ret_r > 0) {
+ /* ok */
+ *ret_r = dbox_mail_parse_mail_header(mail, mbox->file);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static int dbox_mail_open(struct index_mail *mail, uoff_t *offset_r)
+{
+ struct dbox_mailbox *mbox = (struct dbox_mailbox *)mail->ibox;
uint32_t file_seq, prev_file_seq = 0;
- uoff_t offset, prev_offset = 0;
+ uoff_t prev_offset = 0;
int i, ret;
if (mail->mail.mail.expunged)
return 0;
for (i = 0; i < 3; i++) {
- ret = dbox_mail_lookup_offset(mail->trans, seq,
- &file_seq, &offset);
- if (ret <= 0) {
- if (ret == 0)
- mail->mail.mail.expunged = TRUE;
+ if (dbox_mail_try_open(mail, &file_seq, offset_r, &ret))
return ret;
- }
-
- if ((ret = dbox_file_seek(mbox, file_seq, offset)) < 0)
- return -1;
- if (ret > 0) {
- /* ok */
- *offset_r = offset;
- return dbox_mail_parse_mail_header(mail, mbox->file);
- }
- if (prev_file_seq == file_seq && prev_offset == offset) {
+ if (prev_file_seq == file_seq && prev_offset == *offset_r) {
/* broken offset */
break;
+ } else {
+ /* mail was moved. resync dbox to find out the new
+ offset and try again. */
+ if (dbox_sync(mbox, FALSE) < 0)
+ return -1;
}
- /* mail was moved. resync dbox to find out the new offset
- and try again. */
- if (dbox_sync(mbox, FALSE) < 0)
- return -1;
prev_file_seq = file_seq;
- prev_offset = offset;
+ prev_offset = *offset_r;
}
mail_storage_set_critical(STORAGE(mbox->storage),
"Cached message offset (%u, %"PRIuUOFF_T") "
"broken for uid %u in dbox %s",
- file_seq, offset, mail->mail.mail.uid,
+ file_seq, *offset_r, mail->mail.mail.uid,
mbox->path);
+
+ if (dbox_sync(mbox, TRUE) < 0)
+ return -1;
+ if (dbox_mail_try_open(mail, &file_seq, offset_r, &ret))
+ return ret;
return -1;
}
Index: dbox-sync-full.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-sync-full.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- dbox-sync-full.c 18 Apr 2006 18:17:47 -0000 1.5
+++ dbox-sync-full.c 8 Jun 2006 17:14:00 -0000 1.6
@@ -186,7 +186,7 @@
}
hdr = mail_index_get_header(ctx->sync_view);
- while (seq < hdr->messages_count) {
+ while (seq <= hdr->messages_count) {
mail_index_expunge(ctx->trans, seq);
seq++;
}
Index: dbox-uidlist.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-uidlist.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- dbox-uidlist.c 8 Jun 2006 14:42:21 -0000 1.29
+++ dbox-uidlist.c 8 Jun 2006 17:14:00 -0000 1.30
@@ -968,7 +968,7 @@
/* doesn't exist, make sure that index's last file seq is lower */
if (dbox_uidlist_read(mbox->uidlist) < 0)
return -1;
- return file_seq < mbox->uidlist->last_file_seq ? 1 : 0;
+ return file_seq <= mbox->uidlist->last_file_seq ? 1 : 0;
}
static int
@@ -1016,8 +1016,21 @@
to create the file back and cause problems. */
ret = dbox_file_seq_was_used(mbox, str_c(path),
file_seq);
- if (ret == 0)
+
+ if (i < count) {
+ /* dbox file was re-read, find the entry
+ again */
+ entries = array_get(&ctx->uidlist->entries,
+ &count);
+ for (i = 0; i < count; i++) {
+ if (entries[i]->file_seq == file_seq)
+ break;
+ }
+ }
+ if (ret == 0) {
+ i_assert(i < count || !*existing_r);
break;
+ }
/* error / it was used, continue with another
file sequence */
More information about the dovecot-cvs
mailing list