[dovecot-cvs]
dovecot/src/lib-index/maildir maildir-sync.c,1.51,1.52
cras at procontrol.fi
cras at procontrol.fi
Wed Jun 4 17:56:01 EEST 2003
Update of /home/cvs/dovecot/src/lib-index/maildir
In directory danu:/tmp/cvs-serv12431/lib-index/maildir
Modified Files:
maildir-sync.c
Log Message:
Handle syncing better while uidlist is locked.
Index: maildir-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-sync.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- maildir-sync.c 29 May 2003 23:01:47 -0000 1.51
+++ maildir-sync.c 4 Jun 2003 13:55:59 -0000 1.52
@@ -239,6 +239,8 @@
unsigned int readonly_check:1;
unsigned int flag_updates:1;
unsigned int uidlist_rewrite:1;
+ unsigned int new_mails_new:1;
+ unsigned int new_mails_cur:1;
};
static int maildir_sync_cur_dir(struct maildir_sync_context *ctx);
@@ -668,6 +670,7 @@
return FALSE;
}
+ ctx->new_count = 0;
return TRUE;
}
@@ -826,6 +829,11 @@
if (ctx->readonly_check)
continue;
+ if (new_dir)
+ ctx->new_mails_new = TRUE;
+ else
+ ctx->new_mails_cur = TRUE;
+
ctx->new_count++;
hash_rec->action = MAILDIR_FILE_ACTION_NEW | newflag;
hash_insert(ctx->files, p_strdup(ctx->pool, d->d_name),
@@ -1137,7 +1145,9 @@
/* this will set maildir_cur_dirty. it may actually be
different from cur/'s mtime if we're unlucky, but that
doesn't really matter and it's not worth the extra stat() */
- cur_mtime = time(NULL);
+ if (ctx->new_dent == NULL &&
+ (ctx->new_count == 0 || !ctx->new_mails_new))
+ cur_mtime = time(NULL);
}
if (ctx->uidlist_rewrite) {
@@ -1154,13 +1164,22 @@
index->header->flags &= ~MAIL_INDEX_FLAG_MAILDIR_NEW;
}
- if (cur_mtime < ioloop_time - MAILDIR_SYNC_SECS)
- index->maildir_cur_dirty = 0;
- else
- index->maildir_cur_dirty = cur_mtime;
+ if (index->maildir_cur_dirty == 0 ||
+ index->maildir_cur_dirty < ioloop_time - MAILDIR_SYNC_SECS) {
+ if (cur_mtime >= ioloop_time - MAILDIR_SYNC_SECS)
+ index->maildir_cur_dirty = cur_mtime;
+ else if (ctx->new_count == 0 || !ctx->new_mails_cur)
+ index->maildir_cur_dirty = 0;
+ else {
+ /* uidlist is locked, wait for a while before
+ trying again */
+ index->maildir_cur_dirty = ioloop_time;
+ }
+ }
index->file_sync_stamp = cur_mtime;
- if (ctx->new_dent == NULL)
+ if (ctx->new_dent == NULL &&
+ (ctx->new_count == 0 || !ctx->new_mails_new))
index->last_new_mtime = new_mtime;
return TRUE;
More information about the dovecot-cvs
mailing list