Преглед изворни кода

make IMAP pipeline depth configurable

currently, this affects only "clustered" message listings and
flag stores.
Oswald Buddenhagen пре 14 година
родитељ
комит
a85013d6ff
2 измењених фајлова са 18 додато и 2 уклоњено
  1. 9 2
      src/drv_imap.c
  2. 9 0
      src/mbsync.1

+ 9 - 2
src/drv_imap.c

@@ -40,6 +40,7 @@ typedef struct imap_server_conf {
 	server_conf_t sconf;
 	server_conf_t sconf;
 	char *user;
 	char *user;
 	char *pass;
 	char *pass;
+	int max_in_progress;
 #ifdef HAVE_LIBSSL
 #ifdef HAVE_LIBSSL
 	unsigned require_ssl:1;
 	unsigned require_ssl:1;
 	unsigned require_cram:1;
 	unsigned require_cram:1;
@@ -67,7 +68,6 @@ typedef struct _list {
 } list_t;
 } list_t;
 
 
 struct imap_cmd;
 struct imap_cmd;
-#define max_in_progress 50 /* make this configurable? */
 
 
 typedef struct imap_store {
 typedef struct imap_store {
 	store_t gen;
 	store_t gen;
@@ -396,7 +396,7 @@ drain_imap_replies( imap_store_t *ctx )
 static int
 static int
 process_imap_replies( imap_store_t *ctx )
 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 ))
 	       socket_pending( &ctx->conn ))
 		if (get_cmd_result( ctx, 0 ) == RESP_CANCEL)
 		if (get_cmd_result( ctx, 0 ) == RESP_CANCEL)
 			return 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->require_ssl = 1;
 	server->sconf.use_tlsv1 = 1;
 	server->sconf.use_tlsv1 = 1;
 #endif
 #endif
+	server->max_in_progress = 50;
 
 
 	while (getcline( cfg ) && cfg->cmd) {
 	while (getcline( cfg ) && cfg->cmd) {
 		if (!strcasecmp( "Host", 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 );
 			server->pass = nfstrdup( cfg->val );
 		else if (!strcasecmp( "Port", cfg->cmd ))
 		else if (!strcasecmp( "Port", cfg->cmd ))
 			server->sconf.port = parse_int( cfg );
 			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
 #ifdef HAVE_LIBSSL
 		else if (!strcasecmp( "CertificateFile", cfg->cmd )) {
 		else if (!strcasecmp( "CertificateFile", cfg->cmd )) {
 			server->sconf.cert_file = expand_strdup( cfg->val );
 			server->sconf.cert_file = expand_strdup( cfg->val );

+ 9 - 0
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?
 Use TLSv1 for communication with the IMAP server over SSL?
 (Default: \fIyes\fR)
 (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
 .SS IMAP Stores
 The reference point for relative \fBPath\fRs is whatever the server likes it
 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
 to be; probably the user's $HOME or $HOME/Mail on that server. The location