Mercurial > dovecot > core-2.2
changeset 14567:6d11513cdd0d
sdbox: Avoid using too many fds when copying messages.
This happened at least with quota plugin.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 16 May 2012 18:57:05 +0300 |
parents | ca0fef559d43 |
children | bb572accd1af |
files | src/lib-storage/index/dbox-single/sdbox-save.c |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-single/sdbox-save.c Wed May 16 16:14:31 2012 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-save.c Wed May 16 18:57:05 2012 +0300 @@ -78,9 +78,18 @@ void sdbox_save_add_file(struct mail_save_context *_ctx, struct dbox_file *file) { struct sdbox_save_context *ctx = (struct sdbox_save_context *)_ctx; + struct dbox_file *const *files; + unsigned int count; if (ctx->first_saved_seq == 0) ctx->first_saved_seq = ctx->ctx.seq; + + files = array_get(&ctx->files, &count); + if (count > 0) { + /* a plugin may leave a previously saved file open. + we'll close it here to avoid eating too many fds. */ + dbox_file_close(files[count-1]); + } array_append(&ctx->files, &file, 1); }