From a85013d6ff205871d89dac6483ed96da4957b5f0 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sun, 27 Mar 2011 16:58:23 +0200 Subject: [PATCH] make IMAP pipeline depth configurable currently, this affects only "clustered" message listings and flag stores. --- src/drv_imap.c | 11 +++++++++-- src/mbsync.1 | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/drv_imap.c b/src/drv_imap.c index 8b3b98d..779b5ec 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -40,6 +40,7 @@ typedef struct imap_server_conf { server_conf_t sconf; char *user; char *pass; + int max_in_progress; #ifdef HAVE_LIBSSL unsigned require_ssl:1; unsigned require_cram:1; @@ -67,7 +68,6 @@ typedef struct _list { } list_t; struct imap_cmd; -#define max_in_progress 50 /* make this configurable? */ typedef struct imap_store { store_t gen; @@ -396,7 +396,7 @@ drain_imap_replies( imap_store_t *ctx ) static int process_imap_replies( imap_store_t *ctx ) { - while (ctx->num_in_progress > max_in_progress || + while (ctx->num_in_progress > ((imap_store_conf_t *)ctx->gen.conf)->server->max_in_progress || socket_pending( &ctx->conn )) if (get_cmd_result( ctx, 0 ) == RESP_CANCEL) return RESP_CANCEL; @@ -1724,6 +1724,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep, int *err ) server->require_ssl = 1; server->sconf.use_tlsv1 = 1; #endif + server->max_in_progress = 50; while (getcline( cfg ) && cfg->cmd) { if (!strcasecmp( "Host", cfg->cmd )) { @@ -1750,6 +1751,12 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep, int *err ) server->pass = nfstrdup( cfg->val ); else if (!strcasecmp( "Port", cfg->cmd )) server->sconf.port = parse_int( cfg ); + else if (!strcasecmp( "PipelineDepth", cfg->cmd )) { + if ((server->max_in_progress = parse_int( cfg )) < 1) { + error( "%s:%d: PipelineDepth must be at least 1\n", cfg->file, cfg->line ); + *err = 1; + } + } #ifdef HAVE_LIBSSL else if (!strcasecmp( "CertificateFile", cfg->cmd )) { server->sconf.cert_file = expand_strdup( cfg->val ); diff --git a/src/mbsync.1 b/src/mbsync.1 index 04c458b..4f47668 100644 --- a/src/mbsync.1 +++ b/src/mbsync.1 @@ -277,6 +277,15 @@ Use SSLv3 for communication with the IMAP server over SSL? Use TLSv1 for communication with the IMAP server over SSL? (Default: \fIyes\fR) .. +.TP +\fBPipelineDepth\fR \fIdepth\fR +Maximum number of IMAP commands which can be simultaneously in flight. +Setting this to \fI1\fR disables pipelining. +Setting it to a too big value may deadlock isync. +Currently, this affects only a few commands. +This is mostly a debugging only option. +(Default: \fI50\fR) +.. .SS IMAP Stores The reference point for relative \fBPath\fRs is whatever the server likes it to be; probably the user's $HOME or $HOME/Mail on that server. The location