dovecot-2.0: config: Avoid growing data stack / memory pools.

dovecot at dovecot.org dovecot at dovecot.org
Wed Apr 20 18:55:41 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/b8fa3171f6d7
changeset: 12751:b8fa3171f6d7
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Apr 20 18:55:39 2011 +0300
description:
config: Avoid growing data stack / memory pools.

diffstat:

 src/config/config-parser.c |  15 ++++++++-------
 src/config/doveconf.c      |   2 +-
 2 files changed, 9 insertions(+), 8 deletions(-)

diffs (74 lines):

diff -r 7d60cd847c70 -r b8fa3171f6d7 src/config/config-parser.c
--- a/src/config/config-parser.c	Wed Apr 20 18:55:17 2011 +0300
+++ b/src/config/config-parser.c	Wed Apr 20 18:55:39 2011 +0300
@@ -377,7 +377,7 @@
 		return -1;
 	}
 
-	tmp_pool = pool_alloconly_create("config parsers check", 1024*32);
+	tmp_pool = pool_alloconly_create("config parsers check", 1024*64);
 	parsers = array_get(&ctx->all_parsers, &count);
 	i_assert(count > 0 && parsers[count-1] == NULL);
 	count--;
@@ -456,9 +456,9 @@
 		return -1;
 	}
 
-	new_input = t_new(struct input_stack, 1);
+	new_input = p_new(ctx->pool, struct input_stack, 1);
 	new_input->prev = ctx->cur_input;
-	new_input->path = t_strdup(path);
+	new_input->path = p_strdup(ctx->pool, path);
 	new_input->input = i_stream_create_fd(fd, (size_t)-1, TRUE);
 	i_stream_set_return_partial_line(new_input->input, TRUE);
 	ctx->cur_input = new_input;
@@ -870,7 +870,7 @@
 	}
 
 	memset(&ctx, 0, sizeof(ctx));
-	ctx.pool = pool_alloconly_create("config file parser", 1024*64);
+	ctx.pool = pool_alloconly_create("config file parser", 1024*256);
 	ctx.path = path;
 
 	for (count = 0; all_roots[count] != NULL; count++) ;
@@ -894,7 +894,7 @@
 	config_add_new_parser(&ctx);
 
 	ctx.str = str_new(ctx.pool, 256);
-	full_line = t_str_new(512);
+	full_line = str_new(default_pool, 512);
 	ctx.cur_input->input = i_stream_create_fd(fd, (size_t)-1, TRUE);
 	i_stream_set_return_partial_line(ctx.cur_input->input, TRUE);
 	old_settings_init(&ctx);
@@ -910,9 +910,9 @@
 
 		T_BEGIN {
 			handled = old_settings_handle(&ctx, type, key, value);
+			if (!handled)
+				config_parser_apply_line(&ctx, type, key, value);
 		} T_END;
-		if (!handled)
-			config_parser_apply_line(&ctx, type, key, value);
 
 		if (ctx.error != NULL) {
 			*error_r = t_strdup_printf(
@@ -930,6 +930,7 @@
 	if (line == NULL && ctx.cur_input != NULL)
 		goto prevfile;
 
+	str_free(&full_line);
 	if (ret == 0)
 		ret = config_parse_finish(&ctx, error_r);
 	return ret < 0 ? ret : 1;
diff -r 7d60cd847c70 -r b8fa3171f6d7 src/config/doveconf.c
--- a/src/config/doveconf.c	Wed Apr 20 18:55:17 2011 +0300
+++ b/src/config/doveconf.c	Wed Apr 20 18:55:39 2011 +0300
@@ -125,7 +125,7 @@
 	enum config_dump_flags flags;
 	pool_t pool;
 
-	pool = pool_alloconly_create("config human strings", 10240);
+	pool = pool_alloconly_create("config human strings", 1024*32);
 	ctx = p_new(pool, struct config_dump_human_context, 1);
 	ctx->pool = pool;
 	ctx->list_prefix = str_new(ctx->pool, 128);


More information about the dovecot-cvs mailing list