[dovecot-cvs] dovecot/src/lib-index mail-cache-private.h, 1.11, 1.12 mail-cache-transaction.c, 1.16, 1.17

cras at dovecot.org cras at dovecot.org
Tue Jul 20 20:06:28 EEST 2004


Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv22665

Modified Files:
	mail-cache-private.h mail-cache-transaction.c 
Log Message:
Limit how much a single transaction can reserve space



Index: mail-cache-private.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-cache-private.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- mail-cache-private.h	20 Jul 2004 16:50:56 -0000	1.11
+++ mail-cache-private.h	20 Jul 2004 17:06:25 -0000	1.12
@@ -25,6 +25,9 @@
 /* When more space is needed, grow the file n% larger than the previous size */
 #define MAIL_CACHE_GROW_PERCENTAGE 10
 
+/* When allocating space for transactions, don't use blocks larger than this. */
+#define MAIL_CACHE_MAX_RESERVED_BLOCK_SIZE (1024*512)
+
 #define MAIL_CACHE_LOCK_TIMEOUT 120
 #define MAIL_CACHE_LOCK_CHANGE_TIMEOUT 60
 #define MAIL_CACHE_LOCK_IMMEDIATE_TIMEOUT (5*60)

Index: mail-cache-transaction.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-cache-transaction.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- mail-cache-transaction.c	20 Jul 2004 16:50:56 -0000	1.16
+++ mail-cache-transaction.c	20 Jul 2004 17:06:25 -0000	1.17
@@ -179,10 +179,15 @@
 	}
 
 	if (!commit) {
-		size = (size + ctx->last_grow_size) * 2;
-		if ((uoff_t)hdr->used_file_size + size > (uint32_t)-1)
-			size = (uint32_t)-1;
-		ctx->last_grow_size = size;
+		/* allocate some more space than we need */
+		size_t new_size = (size + ctx->last_grow_size) * 2;
+		if ((uoff_t)hdr->used_file_size + new_size > (uint32_t)-1)
+			new_size = (uint32_t)-1;
+		if (new_size > MAIL_CACHE_MAX_RESERVED_BLOCK_SIZE) {
+			new_size = size > MAIL_CACHE_MAX_RESERVED_BLOCK_SIZE ?
+				size : MAIL_CACHE_MAX_RESERVED_BLOCK_SIZE;
+		}
+		ctx->last_grow_size = new_size;
 	}
 
 	if (mail_cache_grow_file(ctx->cache, size) < 0)



More information about the dovecot-cvs mailing list