dovecot-2.0: mdbox_rotate_days changed to mdbox_rotate_interval,...

dovecot at dovecot.org dovecot at dovecot.org
Tue Feb 2 19:03:21 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/b0b63deab22a
changeset: 10630:b0b63deab22a
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Feb 02 19:03:06 2010 +0200
description:
mdbox_rotate_days changed to mdbox_rotate_interval, supporting one second resolution.

diffstat:

4 files changed, 26 insertions(+), 15 deletions(-)
doc/example-config/conf.d/mail.conf               |    6 ++--
src/lib-storage/index/dbox-multi/mdbox-map.c      |   29 ++++++++++++++-------
src/lib-storage/index/dbox-multi/mdbox-settings.c |    4 +-
src/lib-storage/index/dbox-multi/mdbox-settings.h |    2 -

diffs (105 lines):

diff -r bbfa22045215 -r b0b63deab22a doc/example-config/conf.d/mail.conf
--- a/doc/example-config/conf.d/mail.conf	Tue Feb 02 15:20:36 2010 +0200
+++ b/doc/example-config/conf.d/mail.conf	Tue Feb 02 19:03:06 2010 +0200
@@ -310,9 +310,9 @@
 # Minimum dbox file size before it's rotated (overrides mdbox_rotate_days)
 #mdbox_rotate_min_size = 16k
 
-# Maximum dbox file age in days until it's rotated. Day always begins from
-# midnight, so 1 = today, 2 = yesterday, etc. 0 = check disabled.
-#mdbox_rotate_days = 0
+# Maximum dbox file age until it's rotated. Typically in days. Day begins
+# from midnight, so 1d = today, 2d = yesterday, etc. 0 = check disabled.
+#mdbox_rotate_interval = 1d
 
 # Don't purge a dbox file until this many % of it contains expunged messages.
 # 0 purges always, 100 purges never.
diff -r bbfa22045215 -r b0b63deab22a src/lib-storage/index/dbox-multi/mdbox-map.c
--- a/src/lib-storage/index/dbox-multi/mdbox-map.c	Tue Feb 02 15:20:36 2010 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-map.c	Tue Feb 02 19:03:06 2010 +0200
@@ -618,24 +618,35 @@ dbox_map_append_begin(struct dbox_map *m
 	return ctx;
 }
 
-static time_t day_begin_stamp(unsigned int days)
+static time_t day_begin_stamp(unsigned int interval)
 {
 	struct tm tm;
 	time_t stamp;
-
-	if (days == 0)
+	unsigned int unit = 1;
+
+	if (interval == 0)
 		return 0;
 
-	/* get beginning of today */
+	/* get the beginning of day/hour/minute depending on how large
+	   the interval is */
 	tm = *localtime(&ioloop_time);
-	tm.tm_hour = 0;
-	tm.tm_min = 0;
-	tm.tm_sec = 0;
+	if (interval >= 60) {
+		tm.tm_sec = 0;
+		unit = 60;
+		if (interval >= 3600) {
+			tm.tm_min = 0;
+			unit = 3600;
+			if (interval >= 3600*24) {
+				tm.tm_hour = 0;
+				unit = 3600*24;
+			}
+		}
+	}
 	stamp = mktime(&tm);
 	if (stamp == (time_t)-1)
 		i_panic("mktime(today) failed");
 
-	return stamp - (3600*24 * (days-1));
+	return stamp - (interval - unit);
 }
 
 static bool
@@ -753,7 +764,7 @@ dbox_map_find_appendable_file(struct dbo
 	ctx->files_nonappendable_count = count;
 
 	/* try to find an existing appendable file */
-	stamp = day_begin_stamp(map->set->mdbox_rotate_days);
+	stamp = day_begin_stamp(map->set->mdbox_rotate_interval);
 	hdr = mail_index_get_header(map->view);
 
 	ctx->orig_next_uid = hdr->next_uid;
diff -r bbfa22045215 -r b0b63deab22a src/lib-storage/index/dbox-multi/mdbox-settings.c
--- a/src/lib-storage/index/dbox-multi/mdbox-settings.c	Tue Feb 02 15:20:36 2010 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-settings.c	Tue Feb 02 19:03:06 2010 +0200
@@ -17,7 +17,7 @@ static const struct setting_define mdbox
 static const struct setting_define mdbox_setting_defines[] = {
 	DEF(SET_SIZE, mdbox_rotate_size),
 	DEF(SET_SIZE, mdbox_rotate_min_size),
-	DEF(SET_UINT, mdbox_rotate_days),
+	DEF(SET_TIME, mdbox_rotate_interval),
 	DEF(SET_UINT, mdbox_max_open_files),
 	DEF(SET_UINT, mdbox_purge_min_percentage),
 
@@ -27,7 +27,7 @@ static const struct mdbox_settings mdbox
 static const struct mdbox_settings mdbox_default_settings = {
 	.mdbox_rotate_size = 2*1024*1024,
 	.mdbox_rotate_min_size = 16*1024,
-	.mdbox_rotate_days = 0,
+	.mdbox_rotate_interval = 0,
 	.mdbox_max_open_files = 64,
 	.mdbox_purge_min_percentage = 0
 };
diff -r bbfa22045215 -r b0b63deab22a src/lib-storage/index/dbox-multi/mdbox-settings.h
--- a/src/lib-storage/index/dbox-multi/mdbox-settings.h	Tue Feb 02 15:20:36 2010 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-settings.h	Tue Feb 02 19:03:06 2010 +0200
@@ -4,7 +4,7 @@ struct mdbox_settings {
 struct mdbox_settings {
 	uoff_t mdbox_rotate_size;
 	uoff_t mdbox_rotate_min_size;
-	unsigned int mdbox_rotate_days;
+	unsigned int mdbox_rotate_interval;
 	unsigned int mdbox_max_open_files;
 	unsigned int mdbox_purge_min_percentage;
 };


More information about the dovecot-cvs mailing list