#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
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,
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;
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
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;
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;
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;
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;
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;
#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
struct dsync_ibc ibc;
char *name, *temp_path_prefix;
+ unsigned int timeout_secs;
struct istream *input;
struct ostream *output;
struct io *io;
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);
}
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);
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;
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;