changeset 3813:74289963b8a7 HEAD

Added dbox_rotate_size and dbox_rotate_days settings.
author Timo Sirainen <tss@iki.fi>
date Thu, 05 Jan 2006 03:19:42 +0200
parents 2881f7e79098
children dd9849b6977d
files dovecot-example.conf src/lib-storage/index/dbox/dbox-storage.c src/lib-storage/index/dbox/dbox-storage.h src/lib-storage/index/dbox/dbox-uidlist.c src/master/master-settings.c src/master/master-settings.h
diffstat 6 files changed, 35 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/dovecot-example.conf	Thu Jan 05 03:10:46 2006 +0200
+++ b/dovecot-example.conf	Thu Jan 05 03:19:42 2006 +0200
@@ -377,6 +377,13 @@
 # aren't immediately visible to other MUAs.
 #mbox_lazy_writes = yes
 
+# Maximum dbox file size in kilobytes until it's rotated.
+#dbox_rotate_size = 2048
+
+# Maximum dbox file age in days until it's rotated. Day always begins from
+# midnight, so 1 = today, 2 = yesterday, etc. 0 = check disabled.
+#dbox_rotate_days = 0
+
 # umask to use for mail files and directories
 #umask = 0077
 
--- a/src/lib-storage/index/dbox/dbox-storage.c	Thu Jan 05 03:10:46 2006 +0200
+++ b/src/lib-storage/index/dbox/dbox-storage.c	Thu Jan 05 03:19:42 2006 +0200
@@ -275,7 +275,7 @@
 	struct index_storage *istorage = INDEX_STORAGE(storage);
 	struct dbox_mailbox *mbox;
 	struct mail_index *index;
-	const char *path, *index_dir;
+	const char *path, *index_dir, *value;
 	pool_t pool;
 
 	path = dbox_get_path(istorage, name);
@@ -301,6 +301,17 @@
 		return NULL;
 	}
 
+	value = getenv("DBOX_ROTATE_SIZE");
+	if (value != NULL)
+		mbox->rotate_size = (uoff_t)strtoul(value, NULL, 10) * 1024;
+	else
+		mbox->rotate_size = DBOX_DEFAULT_ROTATE_SIZE;
+	value = getenv("DBOX_ROTATE_DAYS");
+	if (value != NULL)
+		mbox->rotate_days = (unsigned int)strtoul(value, NULL, 10);
+	else
+		mbox->rotate_size = DBOX_DEFAULT_ROTATE_DAYS;
+
 	mbox->storage = storage;
 	mbox->path = p_strdup(pool, path);
 	mbox->dbox_file_ext_idx =
--- a/src/lib-storage/index/dbox/dbox-storage.h	Thu Jan 05 03:10:46 2006 +0200
+++ b/src/lib-storage/index/dbox/dbox-storage.h	Thu Jan 05 03:19:42 2006 +0200
@@ -13,6 +13,10 @@
 #define INDEX_STORAGE(mbox_storage) \
 	(&(mbox_storage)->storage)
 
+/* Default rotation settings */
+#define DBOX_DEFAULT_ROTATE_SIZE (2*1024*1024)
+#define DBOX_DEFAULT_ROTATE_DAYS 0
+
 struct dbox_uidlist;
 
 struct dbox_file_header {
@@ -75,6 +79,9 @@
         struct dbox_file *file;
 	uint32_t dbox_file_ext_idx;
 	uint32_t dbox_offset_ext_idx;
+
+	uoff_t rotate_size;
+	unsigned int rotate_days;
 };
 
 struct dbox_transaction_context {
--- a/src/lib-storage/index/dbox/dbox-uidlist.c	Thu Jan 05 03:10:46 2006 +0200
+++ b/src/lib-storage/index/dbox/dbox-uidlist.c	Thu Jan 05 03:19:42 2006 +0200
@@ -21,9 +21,6 @@
 #include <utime.h>
 #include <sys/stat.h>
 
-/* FIXME: configurable */
-#define DBOX_FILE_ROTATE_SIZE (1024*1024*2)
-#define DBOX_FILE_TIMESTAMP_DAYS 1
 #define DBOX_APPEND_MAX_OPEN_FDS 64
 
 #define DBOX_UIDLIST_VERSION 1
@@ -865,13 +862,13 @@
 	time_t min_usable_timestamp;
 	int ret;
 
-        min_usable_timestamp = get_min_timestamp(DBOX_FILE_TIMESTAMP_DAYS);
+        min_usable_timestamp = get_min_timestamp(mbox->rotate_days);
 
 	/* check first from already opened files */
 	files = array_get(&ctx->files, &count);
 	for (i = 0; i < count; i++) {
 		if (files[i]->file->create_time >= min_usable_timestamp ||
-		    files[i]->append_offset < DBOX_FILE_ROTATE_SIZE) {
+		    files[i]->append_offset < mbox->rotate_size) {
 			if (dbox_reopen_file(ctx, files[i]) < 0)
 				return -1;
 
@@ -889,7 +886,7 @@
                 file_seq = 0; 
 		for (; i < count; i++) {
 			if ((entries[i]->create_time >= min_usable_timestamp ||
-			     entries[i]->file_size < DBOX_FILE_ROTATE_SIZE) &&
+			     entries[i]->file_size < mbox->rotate_size) &&
 			    !dbox_uidlist_files_lookup(ctx,
 						       entries[i]->file_seq)) {
 				file_seq = entries[i]->file_seq;
--- a/src/master/master-settings.c	Thu Jan 05 03:10:46 2006 +0200
+++ b/src/master/master-settings.c	Thu Jan 05 03:19:42 2006 +0200
@@ -116,6 +116,8 @@
 	DEF(SET_BOOL, mbox_dirty_syncs),
 	DEF(SET_BOOL, mbox_very_dirty_syncs),
 	DEF(SET_BOOL, mbox_lazy_writes),
+	DEF(SET_INT, dbox_rotate_size),
+	DEF(SET_INT, dbox_rotate_days),
 	DEF(SET_INT, umask),
 	DEF(SET_BOOL, mail_drop_priv_before_exec),
 
@@ -313,6 +315,8 @@
 	MEMBER(mbox_dirty_syncs) TRUE,
 	MEMBER(mbox_very_dirty_syncs) FALSE,
 	MEMBER(mbox_lazy_writes) TRUE,
+	MEMBER(dbox_rotate_size) 2048,
+	MEMBER(dbox_rotate_days) 1,
 	MEMBER(umask) 0077,
 	MEMBER(mail_drop_priv_before_exec) FALSE,
 
--- a/src/master/master-settings.h	Thu Jan 05 03:10:46 2006 +0200
+++ b/src/master/master-settings.h	Thu Jan 05 03:19:42 2006 +0200
@@ -85,6 +85,8 @@
 	int mbox_dirty_syncs;
 	int mbox_very_dirty_syncs;
 	int mbox_lazy_writes;
+	unsigned int dbox_rotate_size;
+	unsigned int dbox_rotate_days;
 	unsigned int umask;
 	int mail_drop_priv_before_exec;