Mercurial > dovecot > core-2.2
changeset 11489:c73ddaa39ca4 HEAD
doveadm: stop and reload commands now run with minimal initialization code.
This allows them to work even if there is something wrong with config file.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 07 Jun 2010 17:48:51 +0100 |
parents | 4b20e692c606 |
children | 48ac56ad4768 |
files | src/doveadm/doveadm.c |
diffstat | 1 files changed, 24 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/doveadm/doveadm.c Mon Jun 07 17:06:17 2010 +0100 +++ b/src/doveadm/doveadm.c Mon Jun 07 17:48:51 2010 +0100 @@ -291,6 +291,7 @@ struct master_service_settings_output output; const char *cmd_name, *error; unsigned int i; + bool quick_init; int c; /* "+" is GNU extension to stop at the first non-option. @@ -310,6 +311,7 @@ return FATAL_DEFAULT; } } + cmd_name = argv[optind]; memset(&input, 0, sizeof(input)); input.roots = set_roots; @@ -323,15 +325,26 @@ i_array_init(&doveadm_cmds, 32); for (i = 0; i < N_ELEMENTS(doveadm_commands); i++) doveadm_register_cmd(doveadm_commands[i]); - doveadm_register_director_commands(); - doveadm_register_log_commands(); - doveadm_mail_init(); - doveadm_load_modules(); - if (optind == argc) - usage_to(stdout, ""); + if (cmd_name != NULL && (strcmp(cmd_name, "stop") == 0 || + strcmp(cmd_name, "reload") == 0)) { + /* special case commands: even if there is something wrong + with the config (e.g. mail_plugins), don't fail these + commands */ + quick_init = TRUE; + } else { + quick_init = FALSE; + doveadm_register_director_commands(); + doveadm_register_log_commands(); + doveadm_mail_init(); + doveadm_load_modules(); - cmd_name = argv[optind]; + if (cmd_name == NULL) { + /* show usage after registering all plugins */ + usage_to(stdout, ""); + } + } + argc -= optind; argv += optind; optind = 1; @@ -349,8 +362,10 @@ usage(); } - doveadm_mail_deinit(); - module_dir_unload(&modules); + if (!quick_init) { + doveadm_mail_deinit(); + module_dir_unload(&modules); + } array_free(&doveadm_cmds); master_service_deinit(&master_service); return 0;