dovecot-1.1: Check and update sync_last_check in one common func...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Feb 25 21:36:46 EET 2008
details: http://hg.dovecot.org/dovecot-1.1/rev/db65d921b0e1
changeset: 7291:db65d921b0e1
user: Timo Sirainen <tss at iki.fi>
date: Mon Feb 25 21:38:58 2008 +0200
description:
Check and update sync_last_check in one common function.
diffstat:
6 files changed, 18 insertions(+), 16 deletions(-)
src/lib-storage/index/cydir/cydir-sync.c | 4 +---
src/lib-storage/index/dbox/dbox-sync.c | 4 +---
src/lib-storage/index/index-storage.h | 2 ++
src/lib-storage/index/index-sync.c | 12 ++++++++++++
src/lib-storage/index/maildir/maildir-sync.c | 6 +-----
src/lib-storage/index/mbox/mbox-sync.c | 6 +-----
diffs (108 lines):
diff -r 697000a67c42 -r db65d921b0e1 src/lib-storage/index/cydir/cydir-sync.c
--- a/src/lib-storage/index/cydir/cydir-sync.c Mon Feb 25 21:37:45 2008 +0200
+++ b/src/lib-storage/index/cydir/cydir-sync.c Mon Feb 25 21:38:58 2008 +0200
@@ -179,9 +179,7 @@ cydir_storage_sync_init(struct mailbox *
if (!box->opened)
index_storage_mailbox_open(&mbox->ibox);
- if ((flags & MAILBOX_SYNC_FLAG_FAST) == 0 ||
- mbox->ibox.sync_last_check + MAILBOX_FULL_SYNC_INTERVAL <=
- ioloop_time)
+ if (index_mailbox_want_full_sync(&mbox->ibox, flags))
ret = cydir_sync(mbox);
return index_mailbox_sync_init(box, flags, ret < 0);
diff -r 697000a67c42 -r db65d921b0e1 src/lib-storage/index/dbox/dbox-sync.c
--- a/src/lib-storage/index/dbox/dbox-sync.c Mon Feb 25 21:37:45 2008 +0200
+++ b/src/lib-storage/index/dbox/dbox-sync.c Mon Feb 25 21:38:58 2008 +0200
@@ -396,9 +396,7 @@ dbox_storage_sync_init(struct mailbox *b
if (!box->opened)
index_storage_mailbox_open(&mbox->ibox);
- if ((flags & MAILBOX_SYNC_FLAG_FAST) == 0 ||
- mbox->ibox.sync_last_check + MAILBOX_FULL_SYNC_INTERVAL <=
- ioloop_time)
+ if (index_mailbox_want_full_sync(&mbox->ibox, flags))
ret = dbox_sync(mbox, FALSE);
return index_mailbox_sync_init(box, flags, ret < 0);
diff -r 697000a67c42 -r db65d921b0e1 src/lib-storage/index/index-storage.h
--- a/src/lib-storage/index/index-storage.h Mon Feb 25 21:37:45 2008 +0200
+++ b/src/lib-storage/index/index-storage.h Mon Feb 25 21:38:58 2008 +0200
@@ -126,6 +126,8 @@ void index_mailbox_check_add(struct inde
const char *path);
void index_mailbox_check_remove_all(struct index_mailbox *ibox);
+bool index_mailbox_want_full_sync(struct index_mailbox *ibox,
+ enum mailbox_sync_flags flags);
struct mailbox_sync_context *
index_mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags,
bool failed);
diff -r 697000a67c42 -r db65d921b0e1 src/lib-storage/index/index-sync.c
--- a/src/lib-storage/index/index-sync.c Mon Feb 25 21:37:45 2008 +0200
+++ b/src/lib-storage/index/index-sync.c Mon Feb 25 21:38:58 2008 +0200
@@ -2,6 +2,7 @@
#include "lib.h"
#include "seq-range-array.h"
+#include "ioloop.h"
#include "array.h"
#include "buffer.h"
#include "index-storage.h"
@@ -18,6 +19,17 @@ struct index_mailbox_sync_context {
bool failed;
};
+
+bool index_mailbox_want_full_sync(struct index_mailbox *ibox,
+ enum mailbox_sync_flags flags)
+{
+ if ((flags & MAILBOX_SYNC_FLAG_FAST) != 0 &&
+ ioloop_time < ibox->sync_last_check + MAILBOX_FULL_SYNC_INTERVAL)
+ return FALSE;
+
+ ibox->sync_last_check = ioloop_time;
+ return TRUE;
+}
void index_mailbox_set_recent_uid(struct index_mailbox *ibox, uint32_t uid)
{
diff -r 697000a67c42 -r db65d921b0e1 src/lib-storage/index/maildir/maildir-sync.c
--- a/src/lib-storage/index/maildir/maildir-sync.c Mon Feb 25 21:37:45 2008 +0200
+++ b/src/lib-storage/index/maildir/maildir-sync.c Mon Feb 25 21:38:58 2008 +0200
@@ -871,11 +871,7 @@ maildir_storage_sync_init(struct mailbox
if (!box->opened)
index_storage_mailbox_open(&mbox->ibox);
- if ((flags & MAILBOX_SYNC_FLAG_FAST) == 0 ||
- mbox->ibox.sync_last_check + MAILBOX_FULL_SYNC_INTERVAL <=
- ioloop_time) {
- mbox->ibox.sync_last_check = ioloop_time;
-
+ if (index_mailbox_want_full_sync(&mbox->ibox, flags)) {
T_BEGIN {
ctx = maildir_sync_context_new(mbox, flags);
ret = maildir_sync_context(ctx, FALSE, NULL,
diff -r 697000a67c42 -r db65d921b0e1 src/lib-storage/index/mbox/mbox-sync.c
--- a/src/lib-storage/index/mbox/mbox-sync.c Mon Feb 25 21:37:45 2008 +0200
+++ b/src/lib-storage/index/mbox/mbox-sync.c Mon Feb 25 21:38:58 2008 +0200
@@ -1555,8 +1555,6 @@ static int mbox_sync_int(struct mbox_mai
((flags & MBOX_SYNC_REWRITE) == 0 &&
getenv("MBOX_LAZY_WRITES") != NULL);
- mbox->ibox.sync_last_check = ioloop_time;
-
if (!mbox->mbox_do_dirty_syncs)
flags |= MBOX_SYNC_UNDIRTY;
@@ -1812,9 +1810,7 @@ mbox_storage_sync_init(struct mailbox *b
if (!box->opened)
index_storage_mailbox_open(&mbox->ibox);
- if ((flags & MAILBOX_SYNC_FLAG_FAST) == 0 ||
- mbox->ibox.sync_last_check + MAILBOX_FULL_SYNC_INTERVAL <=
- ioloop_time) {
+ if (index_mailbox_want_full_sync(&mbox->ibox, flags)) {
if ((flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0 &&
!mbox->mbox_very_dirty_syncs)
mbox_sync_flags |= MBOX_SYNC_UNDIRTY;
More information about the dovecot-cvs
mailing list