Mercurial > dovecot > core-2.2
changeset 18127:3b89f2f4ffb3
doveadm: Avoid calling init() in doveadm binary if the command is sent to doveadm-server.
The init() is still always called when -A or -u *wildcards* are used though.
I'm not sure if that can be delayed. At least all commands should be
verified that they don't rely on the current init() location.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 05 Dec 2014 04:39:11 +0200 |
parents | 7c834633922c |
children | 6dd190bd6dcb |
files | src/doveadm/doveadm-mail.c |
diffstat | 1 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/doveadm/doveadm-mail.c Fri Dec 05 03:53:02 2014 +0200 +++ b/src/doveadm/doveadm-mail.c Fri Dec 05 04:39:11 2014 +0200 @@ -266,7 +266,7 @@ } static int -doveadm_mail_next_user(struct doveadm_mail_cmd_context *ctx, +doveadm_mail_next_user(struct doveadm_mail_cmd_context *ctx, bool init_user, const struct mail_storage_service_input *input, const char **error_r) { @@ -285,6 +285,14 @@ if (ret != 0) return ret; + if (init_user) { + /* call init() after we've checked whether we want to do this + via doveadm-server or not */ + ctx->v.init(ctx, ctx->args); + if (hook_doveadm_mail_init != NULL) + hook_doveadm_mail_init(ctx); + } + ret = mail_storage_service_lookup(ctx->storage_service, input, &ctx->cur_service_user, &error); if (ret <= 0) { @@ -330,11 +338,7 @@ ctx->storage_service_input = *input; ctx->storage_service = mail_storage_service_init(master_service, NULL, ctx->service_flags); - ctx->v.init(ctx, ctx->args); - if (hook_doveadm_mail_init != NULL) - hook_doveadm_mail_init(ctx); - - return doveadm_mail_next_user(ctx, input, error_r); + return doveadm_mail_next_user(ctx, TRUE, input, error_r); } static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED) @@ -379,7 +383,7 @@ ctx->cur_username = user; doveadm_print_sticky("username", user); T_BEGIN { - ret = doveadm_mail_next_user(ctx, &input, &error); + ret = doveadm_mail_next_user(ctx, FALSE, &input, &error); if (ret < 0) i_error("%s", error); else if (ret == 0)