Mercurial > dovecot > core-2.2
changeset 19014:11b107c8dc05
dsync: Added -T parameter to specify the I/O stall timeout.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 26 Aug 2015 15:19:27 +0200 |
parents | adb69a13bc66 |
children | 80efae622dc1 |
files | src/doveadm/doveadm-dsync.c src/doveadm/dsync/dsync-ibc-stream.c src/doveadm/dsync/dsync-ibc.h |
diffstat | 3 files changed, 24 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/doveadm/doveadm-dsync.c Wed Aug 26 15:05:06 2015 +0200 +++ b/src/doveadm/doveadm-dsync.c Wed Aug 26 15:19:27 2015 +0200 @@ -38,7 +38,7 @@ #include <ctype.h> #include <sys/wait.h> -#define DSYNC_COMMON_GETOPT_ARGS "+1a:dEfg:l:m:n:NO:Pr:Rs:t:Ux:" +#define DSYNC_COMMON_GETOPT_ARGS "+1a:dEfg:l:m:n:NO:Pr:Rs:t:T:Ux:" #define DSYNC_REMOTE_CMD_EXIT_WAIT_SECS 30 /* The broken_char is mainly set to get a proper error message when trying to convert a mailbox with a name that can't be used properly translated between @@ -47,6 +47,8 @@ none of them are allowed to be created in regular mailbox names. */ #define DSYNC_LIST_BROKEN_CHAR '\003' +#define DSYNC_DEFAULT_IO_STREAM_TIMEOUT_SECS (60*10) + enum dsync_run_type { DSYNC_RUN_TYPE_LOCAL, DSYNC_RUN_TYPE_STREAM, @@ -64,6 +66,7 @@ ARRAY_TYPE(const_string) exclude_mailboxes; ARRAY_TYPE(const_string) namespace_prefixes; time_t sync_since_timestamp; + unsigned int io_timeout_secs; const char *remote_name; const char *local_location; @@ -485,7 +488,7 @@ i_stream_ref(ctx->input); o_stream_ref(ctx->output); return dsync_ibc_init_stream(ctx->input, ctx->output, - name, temp_prefix); + name, temp_prefix, ctx->io_timeout_secs); } static void @@ -1001,6 +1004,10 @@ if (mail_parse_human_timestamp(optarg, &ctx->sync_since_timestamp) < 0) i_fatal("Invalid -t parameter: %s", optarg); break; + case 'T': + if (str_to_uint(optarg, &ctx->io_timeout_secs) < 0) + i_fatal("Invalid -T parameter: %s", optarg); + break; case 'U': ctx->replicator_notify = TRUE; break; @@ -1015,6 +1022,7 @@ struct dsync_cmd_context *ctx; ctx = doveadm_mail_cmd_alloc(struct dsync_cmd_context); + ctx->io_timeout_secs = DSYNC_DEFAULT_IO_STREAM_TIMEOUT_SECS; ctx->ctx.getopt_args = DSYNC_COMMON_GETOPT_ARGS; ctx->ctx.v.parse_arg = cmd_mailbox_dsync_parse_arg; ctx->ctx.v.preinit = cmd_dsync_preinit; @@ -1036,7 +1044,6 @@ struct dsync_cmd_context *ctx; _ctx = cmd_dsync_alloc(); - _ctx->getopt_args = DSYNC_COMMON_GETOPT_ARGS; ctx = (struct dsync_cmd_context *)_ctx; ctx->backup = TRUE; return _ctx; @@ -1120,6 +1127,10 @@ case 'r': ctx->rawlog_path = optarg; break; + case 'T': + if (str_to_uint(optarg, &ctx->io_timeout_secs) < 0) + i_fatal("Invalid -T parameter: %s", optarg); + break; case 'U': ctx->replicator_notify = TRUE; break; @@ -1134,7 +1145,8 @@ struct dsync_cmd_context *ctx; ctx = doveadm_mail_cmd_alloc(struct dsync_cmd_context); - ctx->ctx.getopt_args = "Er:U"; + ctx->io_timeout_secs = DSYNC_DEFAULT_IO_STREAM_TIMEOUT_SECS; + ctx->ctx.getopt_args = "Er:T:U"; ctx->ctx.v.parse_arg = cmd_mailbox_dsync_server_parse_arg; ctx->ctx.v.run = cmd_dsync_server_run; ctx->sync_type = DSYNC_BRAIN_SYNC_TYPE_CHANGED;
--- a/src/doveadm/dsync/dsync-ibc-stream.c Wed Aug 26 15:05:06 2015 +0200 +++ b/src/doveadm/dsync/dsync-ibc-stream.c Wed Aug 26 15:19:27 2015 +0200 @@ -24,7 +24,6 @@ #include <stdlib.h> -#define DSYNC_IBC_STREAM_TIMEOUT_MSECS (60*10*1000) #define DSYNC_IBC_STREAM_OUTBUF_THROTTLE_SIZE (1024*128) #define DSYNC_PROTOCOL_VERSION_MAJOR 3 @@ -142,6 +141,7 @@ struct dsync_ibc ibc; char *name, *temp_path_prefix; + unsigned int timeout_secs; struct istream *input; struct ostream *output; struct io *io; @@ -291,7 +291,7 @@ static void dsync_ibc_stream_timeout(struct dsync_ibc_stream *ibc) { i_error("dsync(%s): I/O has stalled, no activity for %u seconds", - ibc->name, DSYNC_IBC_STREAM_TIMEOUT_MSECS/1000); + ibc->name, ibc->timeout_secs); ibc->ibc.timeout = TRUE; dsync_ibc_stream_stop(ibc); } @@ -303,7 +303,7 @@ ibc->io = io_add_istream(ibc->input, dsync_ibc_stream_input, ibc); o_stream_set_no_error_handling(ibc->output, TRUE); o_stream_set_flush_callback(ibc->output, dsync_ibc_stream_output, ibc); - ibc->to = timeout_add(DSYNC_IBC_STREAM_TIMEOUT_MSECS, + ibc->to = timeout_add(ibc->timeout_secs * 1000, dsync_ibc_stream_timeout, ibc); o_stream_cork(ibc->output); o_stream_nsend_str(ibc->output, DSYNC_HANDSHAKE_VERSION); @@ -1943,7 +1943,8 @@ struct dsync_ibc * dsync_ibc_init_stream(struct istream *input, struct ostream *output, - const char *name, const char *temp_path_prefix) + const char *name, const char *temp_path_prefix, + unsigned int timeout_secs) { struct dsync_ibc_stream *ibc; @@ -1953,6 +1954,7 @@ ibc->output = output; ibc->name = i_strdup(name); ibc->temp_path_prefix = i_strdup(temp_path_prefix); + ibc->timeout_secs = timeout_secs; ibc->ret_pool = pool_alloconly_create("ibc stream data", 2048); dsync_ibc_stream_init(ibc); return &ibc->ibc;
--- a/src/doveadm/dsync/dsync-ibc.h Wed Aug 26 15:05:06 2015 +0200 +++ b/src/doveadm/dsync/dsync-ibc.h Wed Aug 26 15:19:27 2015 +0200 @@ -70,7 +70,8 @@ struct dsync_ibc **ibc2_r); struct dsync_ibc * dsync_ibc_init_stream(struct istream *input, struct ostream *output, - const char *name, const char *temp_path_prefix); + const char *name, const char *temp_path_prefix, + unsigned int timeout_secs); void dsync_ibc_deinit(struct dsync_ibc **ibc); /* I/O callback is called whenever new data is available. It's also called on