dovecot: Avoid growing data stack too large.

dovecot at dovecot.org dovecot at dovecot.org
Sat Nov 10 22:55:59 EET 2007


details:   http://hg.dovecot.org/dovecot/rev/8a342eab2f5e
changeset: 6764:8a342eab2f5e
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Nov 10 22:55:55 2007 +0200
description:
Avoid growing data stack too large.

diffstat:

2 files changed, 10 insertions(+), 4 deletions(-)
src/lib-storage/index/dbox/dbox-index.c        |    5 ++++-
src/lib-storage/index/dbox/dbox-sync-rebuild.c |    9 ++++++---

diffs (62 lines):

diff -r b393080f6911 -r 8a342eab2f5e src/lib-storage/index/dbox/dbox-index.c
--- a/src/lib-storage/index/dbox/dbox-index.c	Sat Nov 10 22:54:48 2007 +0200
+++ b/src/lib-storage/index/dbox/dbox-index.c	Sat Nov 10 22:55:55 2007 +0200
@@ -862,14 +862,16 @@ int dbox_index_append_assign_file_ids(st
 	unsigned int i, count;
 	int ret = 0;
 
-	str = t_str_new(1024);
+	str = str_new(default_pool, 1024);
 	files = array_get(&ctx->files, &count);
 	for (i = 0; i < count; i++) {
 		file = files[i];
 
 		if (file->file_id == 0) {
+			t_push();
 			if (dbox_index_append_commit_new(ctx, file, str) < 0)
 				ret = -1;
+			t_pop();
 		}
 	}
 
@@ -881,6 +883,7 @@ int dbox_index_append_assign_file_ids(st
 		/* we have to rollback changes we made */
 		dbox_index_append_rollback_commit(ctx);
 	}
+	str_free(&str);
 	return ret;
 }
 
diff -r b393080f6911 -r 8a342eab2f5e src/lib-storage/index/dbox/dbox-sync-rebuild.c
--- a/src/lib-storage/index/dbox/dbox-sync-rebuild.c	Sat Nov 10 22:54:48 2007 +0200
+++ b/src/lib-storage/index/dbox/dbox-sync-rebuild.c	Sat Nov 10 22:55:55 2007 +0200
@@ -283,6 +283,7 @@ static int dbox_sync_index_rebuild_dir(s
 	}
 	errno = 0;
 	for (; ret == 0 && (d = readdir(dir)) != NULL; errno = 0) {
+		t_push();
 		if (strncmp(d->d_name, DBOX_MAIL_FILE_UID_PREFIX,
 			    sizeof(DBOX_MAIL_FILE_UID_PREFIX)-1) == 0)
 			ret = dbox_sync_index_uid_file(ctx, path, d->d_name);
@@ -291,6 +292,7 @@ static int dbox_sync_index_rebuild_dir(s
 			ret = dbox_sync_index_multi_file(ctx, path, d->d_name);
 		else if (primary && strstr(d->d_name, ":2,") != NULL)
 			ret = dbox_sync_index_maildir_file(ctx, d->d_name);
+		t_pop();
 	}
 	if (errno != 0) {
 		mail_storage_set_critical(storage,
@@ -331,9 +333,10 @@ static int dbox_sync_new_maildir(struct 
 		hdr = mail_index_get_header(trans_view);
 		ctx->maildir_new_uid = hdr->next_uid;
 	}
-	for (i = 0; i < count; i++) {
-		if (dbox_sync_index_maildir_file(ctx, fnames[i]) < 0)
-			ret = -1;
+	for (i = 0; i < count && ret == 0; i++) {
+		t_push();
+		ret = dbox_sync_index_maildir_file(ctx, fnames[i]);
+		t_pop();
 	}
 	return ret;
 }


More information about the dovecot-cvs mailing list