[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-sync.c,
1.12, 1.13 maildir-uidlist.c, 1.13, 1.14 maildir-uidlist.h, 1.4, 1.5
cras at procontrol.fi
cras at procontrol.fi
Mon May 10 02:06:29 EEST 2004
Update of /home/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv29121/lib-storage/index/maildir
Modified Files:
maildir-sync.c maildir-uidlist.c maildir-uidlist.h
Log Message:
syncing fixes
Index: maildir-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-sync.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- maildir-sync.c 6 May 2004 01:22:25 -0000 1.12
+++ maildir-sync.c 9 May 2004 23:06:27 -0000 1.13
@@ -392,8 +392,13 @@
ret = maildir_uidlist_sync_next_pre(ctx->uidlist_sync_ctx,
dp->d_name);
- if (ret == 0)
+ if (ret == 0) {
+ if (new_dir)
+ ctx->ibox->last_new_mtime = 0;
+ else
+ ctx->ibox->dirty_cur_time = ioloop_time;
continue;
+ }
if (ret < 0)
break;
@@ -406,7 +411,7 @@
if (strchr(dp->d_name, ':') == NULL)
str_append(dest, ":2,");
if (rename(str_c(src), str_c(dest)) == 0) {
- /* we moved it - it's \Recent for use */
+ /* we moved it - it's \Recent for us */
ctx->ibox->dirty_cur_time = ioloop_time;
flags |= MAILDIR_UIDLIST_REC_FLAG_MOVED |
MAILDIR_UIDLIST_REC_FLAG_RECENT;
@@ -495,9 +500,11 @@
/* cur/ changed, or delayed cur/ check */
*cur_changed_r = TRUE;
ibox->last_cur_mtime = cur_mtime;
+
+ ibox->dirty_cur_time =
+ cur_mtime >= ioloop_time - MAILDIR_SYNC_SECS ?
+ cur_mtime : 0;
}
- ibox->dirty_cur_time =
- cur_mtime >= ioloop_time - MAILDIR_SYNC_SECS ? cur_mtime : 0;
return 0;
}
@@ -547,6 +554,17 @@
}
if (seq > hdr->messages_count) {
+ if (uid < hdr->next_uid) {
+ /* message not in index, but next_uid header
+ is updated? shouldn't really happen.. */
+ mail_storage_set_critical(ibox->box.storage,
+ "Maildir sync: UID < next_uid "
+ "(%u < %u)", uid, hdr->next_uid);
+ mail_index_mark_corrupted(ibox->index);
+ ret = -1;
+ break;
+ }
+
mail_index_append(trans, uid, &seq);
mail_index_update_flags(trans, seq, MODIFY_REPLACE,
flags, keywords);
@@ -570,7 +588,8 @@
shouldn't happen */
mail_storage_set_critical(ibox->box.storage,
"Maildir sync: UID inserted in the middle "
- "of mailbox (%u > %u)", rec->uid, uid);
+ "of mailbox (%u > %u, file = %s)",
+ rec->uid, uid, filename);
mail_index_mark_corrupted(ibox->index);
ret = -1;
break;
@@ -586,6 +605,8 @@
if ((uint8_t)flags != (rec->flags & MAIL_FLAGS_MASK) ||
memcmp(keywords, rec->keywords,
INDEX_KEYWORDS_BYTE_COUNT) != 0) {
+ /* FIXME: this is wrong if there's syncs later.
+ it gets fixed in next sync however.. */
mail_index_update_flags(trans, seq, MODIFY_REPLACE,
flags, keywords);
}
@@ -656,11 +677,14 @@
return -1;
}
+ /* finish uidlist syncing, but keep it still locked */
+ maildir_uidlist_sync_finish(ctx->uidlist_sync_ctx);
+ if (maildir_sync_index(ctx) < 0)
+ return -1;
+
ret = maildir_uidlist_sync_deinit(ctx->uidlist_sync_ctx);
ctx->uidlist_sync_ctx = NULL;
- if (ret == 0)
- ret = maildir_sync_index(ctx);
return ret;
}
Index: maildir-uidlist.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-uidlist.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- maildir-uidlist.c 6 May 2004 01:22:25 -0000 1.13
+++ maildir-uidlist.c 9 May 2004 23:06:27 -0000 1.14
@@ -59,6 +59,7 @@
unsigned int partial:1;
unsigned int synced:1;
unsigned int locked:1;
+ unsigned int finished:1;
unsigned int failed:1;
};
@@ -176,6 +177,8 @@
uidlist->fname, uid, uidlist->last_read_uid);
return 0;
}
+ uidlist->last_read_uid = uid;
+
if (uid >= uidlist->next_uid) {
mail_storage_set_critical(uidlist->ibox->box.storage,
"UID larger than next_uid in file %s (%u >= %u)",
@@ -636,6 +639,8 @@
struct maildir_uidlist *uidlist = ctx->uidlist;
struct maildir_uidlist_rec *rec, *old_rec;
+ i_assert(!ctx->locked);
+
if (ctx->failed)
return -1;
@@ -761,10 +766,8 @@
}
}
-int maildir_uidlist_sync_deinit(struct maildir_uidlist_sync_ctx *ctx)
+void maildir_uidlist_sync_finish(struct maildir_uidlist_sync_ctx *ctx)
{
- int ret = ctx->failed ? -1 : 0;
-
if (!ctx->partial) {
if (!ctx->failed && !ctx->locked)
maildir_uidlist_swap(ctx);
@@ -775,6 +778,15 @@
}
maildir_uidlist_mark_all(ctx->uidlist, FALSE);
}
+ ctx->finished = TRUE;
+}
+
+int maildir_uidlist_sync_deinit(struct maildir_uidlist_sync_ctx *ctx)
+{
+ int ret = ctx->failed ? -1 : 0;
+
+ if (!ctx->finished)
+ maildir_uidlist_sync_finish(ctx);
if (ctx->new_files_count != 0 && !ctx->failed && !ctx->locked)
ret = maildir_uidlist_rewrite(ctx->uidlist);
Index: maildir-uidlist.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-uidlist.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- maildir-uidlist.h 6 May 2004 01:22:25 -0000 1.4
+++ maildir-uidlist.h 9 May 2004 23:06:27 -0000 1.5
@@ -37,6 +37,7 @@
int maildir_uidlist_sync_next(struct maildir_uidlist_sync_ctx *ctx,
const char *filename,
enum maildir_uidlist_rec_flag flags);
+void maildir_uidlist_sync_finish(struct maildir_uidlist_sync_ctx *ctx);
int maildir_uidlist_sync_deinit(struct maildir_uidlist_sync_ctx *ctx);
/* List all maildir files. */
More information about the dovecot-cvs
mailing list