[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-storage.c, 1.1, 1.2 dbox-storage.h, 1.2, 1.3 dbox-uidlist.c, 1.6, 1.7

cras at dovecot.org cras at dovecot.org
Thu Jan 5 03:19:45 EET 2006


Update of /var/lib/cvs/dovecot/src/lib-storage/index/dbox
In directory talvi:/tmp/cvs-serv29705/src/lib-storage/index/dbox

Modified Files:
	dbox-storage.c dbox-storage.h dbox-uidlist.c 
Log Message:
Added dbox_rotate_size and dbox_rotate_days settings.



Index: dbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-storage.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dbox-storage.c	27 Nov 2005 23:05:29 -0000	1.1
+++ dbox-storage.c	5 Jan 2006 01:19:43 -0000	1.2
@@ -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 =

Index: dbox-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-storage.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- dbox-storage.h	5 Jan 2006 01:10:46 -0000	1.2
+++ dbox-storage.h	5 Jan 2006 01:19:43 -0000	1.3
@@ -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 {

Index: dbox-uidlist.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-uidlist.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- dbox-uidlist.c	5 Jan 2006 01:10:46 -0000	1.6
+++ dbox-uidlist.c	5 Jan 2006 01:19:43 -0000	1.7
@@ -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;



More information about the dovecot-cvs mailing list