From: Timo Sirainen Date: Mon, 24 Oct 2016 19:42:43 +0000 (+0300) Subject: doveadm director flush: Added --max-parallel parameter. X-Git-Tag: 2.2.26~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f3afdea8a476341d818b5cee794b872e581ef006;p=thirdparty%2Fdovecot%2Fcore.git doveadm director flush: Added --max-parallel parameter. --- diff --git a/src/doveadm/doveadm-director.c b/src/doveadm/doveadm-director.c index 25b0e399f9..4fce99d324 100644 --- a/src/doveadm/doveadm-director.c +++ b/src/doveadm/doveadm-director.c @@ -33,6 +33,7 @@ struct director_context { struct istream *input; bool explicit_socket_path; bool hash_map, user_map, force_flush; + int64_t max_parallel; }; struct user_list { @@ -128,6 +129,8 @@ cmd_director_init(struct doveadm_cmd_context *cctx) ctx->vhost_count = NULL; if (!doveadm_cmd_param_str(cctx, "passdb-field", &(ctx->passdb_field))) ctx->passdb_field = NULL; + if (!doveadm_cmd_param_int64(cctx, "max-parallel", &(ctx->max_parallel))) + ctx->max_parallel = 0; if (!ctx->user_map) director_connect(ctx); return ctx; @@ -629,8 +632,15 @@ static void cmd_director_flush_all(struct director_context *ctx) { const char *line; - director_send(ctx, ctx->force_flush ? - "HOST-FLUSH\n" : "HOST-RESET-USERS\n"); + if (ctx->force_flush) + line = "HOST-FLUSH\n"; + else if (ctx->max_parallel > 0) { + line = t_strdup_printf("HOST-RESET-USERS\t\t%lld\n", + (long long)ctx->max_parallel); + } else { + line = "HOST-RESET-USERS\n"; + } + director_send(ctx, line); line = i_stream_read_next_line(ctx->input); if (line == NULL) { @@ -651,6 +661,7 @@ static void cmd_director_flush(struct doveadm_cmd_context *cctx) unsigned int i, ips_count; struct ip_addr ip; const char *line; + string_t *cmd; ctx = cmd_director_init(cctx); if (ctx->host == NULL) { @@ -669,10 +680,20 @@ static void cmd_director_flush(struct doveadm_cmd_context *cctx) if (director_get_host(ctx->host, &ips, &ips_count) != 0) return; } + cmd = t_str_new(64); for (i = 0; i < ips_count; i++) { - director_send(ctx, t_strdup_printf("%s\t%s\n", - ctx->force_flush ? "HOST-FLUSH" : "HOST-RESET-USERS", - net_ip2addr(&ip))); + str_truncate(cmd, 0); + if (ctx->force_flush) + str_printfa(cmd, "HOST-FLUSH\t%s\n", net_ip2addr(&ip)); + else { + str_printfa(cmd, "HOST-RESET-USERS\t%s", net_ip2addr(&ip)); + if (ctx->max_parallel > 0) { + str_printfa(cmd, "\t%lld", + (long long)ctx->max_parallel); + } + str_append_c(cmd, '\n'); + } + director_send(ctx, str_c(cmd)); } for (i = 0; i < ips_count; i++) { line = i_stream_read_next_line(ctx->input); @@ -942,10 +963,11 @@ DOVEADM_CMD_PARAMS_END { .name = "director flush", .cmd = cmd_director_flush, - .usage = "[-a ] [-F] |all", + .usage = "[-a ] [-F] [--max-parallel ] |all", DOVEADM_CMD_PARAMS_START DOVEADM_CMD_PARAM('a', "socket-path", CMD_PARAM_STR, 0) DOVEADM_CMD_PARAM('F', "force-flush", CMD_PARAM_BOOL, 0) +DOVEADM_CMD_PARAM('\0', "max-parallel", CMD_PARAM_INT64, 0) DOVEADM_CMD_PARAM('\0', "host", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL) DOVEADM_CMD_PARAMS_END },