dovecot-1.2: Implemented support for ESORT capability.

dovecot at dovecot.org dovecot at dovecot.org
Wed Feb 4 21:59:47 EET 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/bbdbab5354d6
changeset: 8714:bbdbab5354d6
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Feb 04 14:58:35 2009 -0500
description:
Implemented support for ESORT capability.

diffstat:

9 files changed, 681 insertions(+), 670 deletions(-)
TODO                   |   24 +
configure.in           |    2 
src/imap/Makefile.am   |    4 
src/imap/cmd-search.c  |  533 -------------------------------------------
src/imap/cmd-sort.c    |   30 +-
src/imap/imap-search.c |  588 ++++++++++++++++++++++++++++++++++++++++++++++++
src/imap/imap-search.h |   50 ++++
src/imap/imap-sort.c   |  113 ---------
src/imap/imap-sort.h   |    7 

diffs (truncated from 1492 to 300 lines):

diff -r 0118c6040468 -r bbdbab5354d6 TODO
--- a/TODO	Wed Feb 04 14:18:24 2009 -0500
+++ b/TODO	Wed Feb 04 14:58:35 2009 -0500
@@ -1,3 +1,20 @@
+dovecot: Jan 17 17:04:38 Panic: dict: file driver-pgsql.c: line 202 (driver_pgsql_init_v): assertion failed: (connect_string != NULL)
+  ^ kun puuttui connect setting
+
+dovecot: Jan 17 17:05:58 Error: dict: io_loop_handle_remove: epoll_ctl(2, 9): No such file or directory
+dovecot: Jan 17 17:05:58 Error: dict: pgsql: Connect failed to mails: FATAL:  password authentication failed for user "timo"
+
+dovecot: Jan 17 17:13:07 Error: dict: dict sql lookup failed: FATAL:  terminating connection due to administrator command
+dovecot: Jan 17 17:13:07 Error: dict: io_loop_handle_remove: epoll_ctl(2, 9): Bad file descriptor
+
+Jan 16 02:30:12 vh3 dovecot: auth(default): sql(user at ex2.com): User query failed: FATAL:  terminating connection due to administrator command
+Jan 16 02:30:12 vh3 deliver(user at ex2.com): Auth lookup returned failure
+Jan 16 02:30:12 vh3 dovecot: auth(default): kevent(EV_DELETE, 10) failed: Bad file descriptor
+
+ - namespace shared: prefix = shared/%%d/%%u/: LIST shared/% doesn't work
+ - index_removal_timeout leak when copy&pasting:
+     10 myrights "INBOX"
+     11 getacl "INBOX"
  - proxying: support fallbacking to local (or other?) server if the first
    one is down
 user_attrs {
@@ -13,6 +30,8 @@ safe_mkstemp(/usr/local/var/run/dovecot/
 safe_mkstemp(/usr/local/var/run/dovecot/user-not-found/test/temp.hurina.12890.87eb6b37b351b733) failed: No such file or directory
 
  - i_panic("Message count decreased") happens - why?
+     - at least one backtrace shows client_destroy -> client_command_cancel ->
+       imap_sync_deinit
  - fts-solr: handle DELETE, RENAME
  - fsck -> log_file_tail_offset 2273345664 -> 996 ->
    mail-transaction-log.c: line 341 (mail_transaction_log_set_mailbox_sync_pos):
@@ -32,11 +51,8 @@ safe_mkstemp(/usr/local/var/run/dovecot/
       dovecot-acl files? at least not that often..
  - virtual mailboxes: backend mailbox where to save mails if they're tried to
    be saved to the virtual mailbox.
- - acl example in wiki with acl_dict = file:/var/mail/%d/dovecot.shared
+ - acl example in wiki with acl_shared_dict = file:/var/mail/%d/dovecot.shared
   - with list=children
- - change auth_worker_max_request_count to non-zero by default? at least with
-   PAM it should be non-zero.. perhaps remove the entire setting and make it
-   a pam args?
  - add anonymous environment for anon logins
  - fs quota: getquotaroot inbox vs. other-box should return different quotas
    if two quotas are defined
diff -r 0118c6040468 -r bbdbab5354d6 configure.in
--- a/configure.in	Wed Feb 04 14:18:24 2009 -0500
+++ b/configure.in	Wed Feb 04 14:58:35 2009 -0500
@@ -2340,7 +2340,7 @@ dnl **
 dnl **
 
 capability_banner="IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE"
-capability="$capability_banner SORT THREAD=REFERENCES MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH SEARCHRES WITHIN CONTEXT=SEARCH"
+capability="$capability_banner SORT THREAD=REFERENCES MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH"
 AC_DEFINE_UNQUOTED(CAPABILITY_STRING, "$capability", IMAP capabilities)
 AC_DEFINE_UNQUOTED(CAPABILITY_BANNER_STRING, "$capability_banner", IMAP capabilities advertised in banner) 
 
diff -r 0118c6040468 -r bbdbab5354d6 src/imap/Makefile.am
--- a/src/imap/Makefile.am	Wed Feb 04 14:18:24 2009 -0500
+++ b/src/imap/Makefile.am	Wed Feb 04 14:58:35 2009 -0500
@@ -71,8 +71,8 @@ imap_SOURCES = \
 	imap-expunge.c \
 	imap-fetch.c \
 	imap-fetch-body.c \
+	imap-search.c \
 	imap-search-args.c \
-	imap-sort.c \
 	imap-status.c \
 	imap-sync.c \
 	mail-storage-callbacks.c \
@@ -86,8 +86,8 @@ headers = \
 	common.h \
 	imap-expunge.h \
 	imap-fetch.h \
+	imap-search.h \
 	imap-search-args.h \
-	imap-sort.h \
 	imap-status.h \
 	imap-sync.h
 
diff -r 0118c6040468 -r bbdbab5354d6 src/imap/cmd-search.c
--- a/src/imap/cmd-search.c	Wed Feb 04 14:18:24 2009 -0500
+++ b/src/imap/cmd-search.c	Wed Feb 04 14:58:35 2009 -0500
@@ -1,501 +1,11 @@
 /* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */
 
 #include "common.h"
-#include "ostream.h"
-#include "str.h"
-#include "seq-range-array.h"
-#include "imap-resp-code.h"
-#include "imap-quote.h"
-#include "imap-seqset.h"
-#include "imap-util.h"
-#include "mail-search-build.h"
-#include "commands.h"
 #include "imap-search-args.h"
-
-enum search_return_options {
-	SEARCH_RETURN_ESEARCH		= 0x0001,
-	SEARCH_RETURN_MIN		= 0x0002,
-	SEARCH_RETURN_MAX		= 0x0004,
-	SEARCH_RETURN_ALL		= 0x0008,
-	SEARCH_RETURN_COUNT		= 0x0010,
-	SEARCH_RETURN_MODSEQ		= 0x0020,
-	SEARCH_RETURN_SAVE		= 0x0040,
-	SEARCH_RETURN_UPDATE		= 0x0080,
-	SEARCH_RETURN_PARTIAL		= 0x0100
-/* Options that don't return any seq/uid results */
-#define SEARCH_RETURN_NORESULTS \
-	(SEARCH_RETURN_ESEARCH | SEARCH_RETURN_MODSEQ | SEARCH_RETURN_SAVE | \
-	 SEARCH_RETURN_UPDATE)
-};
-
-struct imap_search_context {
-	struct client_command_context *cmd;
-	struct mailbox *box;
-	struct mailbox_transaction_context *trans;
-        struct mail_search_context *search_ctx;
-	struct mail *mail;
-
-	struct mail_search_args *sargs;
-	enum search_return_options return_options;
-	uint32_t partial1, partial2;
-
-	struct timeout *to;
-	ARRAY_TYPE(seq_range) result;
-	unsigned int result_count;
-
-	uint64_t highest_seen_modseq;
-	struct timeval start_time;
-
-	unsigned int have_seqsets:1;
-	unsigned int have_modseqs:1;
-};
-
-static int
-imap_partial_range_parse(struct imap_search_context *ctx, const char *str)
-{
-	ctx->partial1 = 0;
-	ctx->partial2 = 0;
-	for (; *str >= '0' && *str <= '9'; str++)
-		ctx->partial1 = ctx->partial1 * 10 + *str-'0';
-	if (*str != ':' || ctx->partial1 == 0)
-		return -1;
-	for (str++; *str >= '0' && *str <= '9'; str++)
-		ctx->partial2 = ctx->partial2 * 10 + *str-'0';
-	if (*str != '\0' || ctx->partial2 == 0)
-		return -1;
-
-	if (ctx->partial1 > ctx->partial2) {
-		uint32_t temp = ctx->partial2;
-		ctx->partial2 = ctx->partial1;
-		ctx->partial1 = temp;
-	}
-
-	return 0;
-}
-
-static bool
-search_parse_return_options(struct imap_search_context *ctx,
-			    const struct imap_arg *args)
-{
-	struct client_command_context *cmd = ctx->cmd;
-	const char *name, *str;
-	unsigned int idx;
-
-	while (args->type != IMAP_ARG_EOL) {
-		if (args->type != IMAP_ARG_ATOM) {
-			client_send_command_error(cmd,
-				"SEARCH return options contain non-atoms.");
-			return FALSE;
-		}
-		name = t_str_ucase(IMAP_ARG_STR_NONULL(args));
-		args++;
-		if (strcmp(name, "MIN") == 0)
-			ctx->return_options |= SEARCH_RETURN_MIN;
-		else if (strcmp(name, "MAX") == 0)
-			ctx->return_options |= SEARCH_RETURN_MAX;
-		else if (strcmp(name, "ALL") == 0)
-			ctx->return_options |= SEARCH_RETURN_ALL;
-		else if (strcmp(name, "COUNT") == 0)
-			ctx->return_options |= SEARCH_RETURN_COUNT;
-		else if (strcmp(name, "SAVE") == 0)
-			ctx->return_options |= SEARCH_RETURN_SAVE;
-		else if (strcmp(name, "UPDATE") == 0)
-			ctx->return_options |= SEARCH_RETURN_UPDATE;
-		else if (strcmp(name, "PARTIAL") == 0) {
-			if (ctx->partial1 != 0) {
-				client_send_command_error(cmd,
-					"PARTIAL can be used only once.");
-				return FALSE;
-			}
-			ctx->return_options |= SEARCH_RETURN_PARTIAL;
-			if (args->type != IMAP_ARG_ATOM) {
-				client_send_command_error(cmd,
-					"PARTIAL range missing.");
-				return FALSE;
-			}
-			str = IMAP_ARG_STR_NONULL(args);
-			if (imap_partial_range_parse(ctx, str) < 0) {
-				client_send_command_error(cmd,
-					"PARTIAL range broken.");
-				return FALSE;
-			}
-			args++;
-		} else {
-			client_send_command_error(cmd,
-				"Unknown SEARCH return option");
-			return FALSE;
-		}
-	}
-
-	if ((ctx->return_options & SEARCH_RETURN_UPDATE) != 0 &&
-	    client_search_update_lookup(cmd->client, cmd->tag, &idx) != NULL) {
-		client_send_command_error(cmd, "Duplicate search update tag");
-		return FALSE;
-	}
-	if ((ctx->return_options & SEARCH_RETURN_PARTIAL) != 0 &&
-	    (ctx->return_options & SEARCH_RETURN_ALL) != 0) {
-		client_send_command_error(cmd, "PARTIAL conflicts with ALL");
-		return FALSE;
-	}
-
-	if (ctx->return_options == 0)
-		ctx->return_options = SEARCH_RETURN_ALL;
-	ctx->return_options |= SEARCH_RETURN_ESEARCH;
-	return TRUE;
-}
-
-static void imap_search_args_check(struct imap_search_context *ctx,
-				   const struct mail_search_arg *sargs)
-{
-	for (; sargs != NULL; sargs = sargs->next) {
-		switch (sargs->type) {
-		case SEARCH_SEQSET:
-			ctx->have_seqsets = TRUE;
-			break;
-		case SEARCH_MODSEQ:
-			ctx->have_modseqs = TRUE;
-			break;
-		case SEARCH_OR:
-		case SEARCH_SUB:
-			imap_search_args_check(ctx, sargs->value.subargs);
-			break;
-		default:
-			break;
-		}
-	}
-}
-
-static void imap_search_result_save(struct imap_search_context *ctx)
-{
-	struct client *client = ctx->cmd->client;
-	struct mail_search_result *result;
-	struct imap_search_update *update;
-
-	if (!array_is_created(&client->search_updates))
-		i_array_init(&client->search_updates, 32);
-	else if (array_count(&client->search_updates) >=
-		 CLIENT_MAX_SEARCH_UPDATES) {
-		/* too many updates */
-		string_t *str = t_str_new(256);
-		str_append(str, "* NO [NOUPDATE ");
-		imap_quote_append_string(str, ctx->cmd->tag, FALSE);
-		str_append_c(str, ']');
-		client_send_line(client, str_c(str));
-		ctx->return_options &= ~SEARCH_RETURN_UPDATE;
-		return;
-	}
-	result = mailbox_search_result_save(ctx->search_ctx,
-					MAILBOX_SEARCH_RESULT_FLAG_UPDATE |
-					MAILBOX_SEARCH_RESULT_FLAG_QUEUE_SYNC);
-
-	update = array_append_space(&client->search_updates);
-	update->tag = i_strdup(ctx->cmd->tag);
-	update->result = result;
-	update->return_uids = ctx->cmd->uid;
-}
-
-static void
-imap_search_init(struct imap_search_context *ctx,
-		 struct mail_search_args *sargs)
-{
-	imap_search_args_check(ctx, sargs->args);
-
-	if (ctx->have_modseqs) {
-		ctx->return_options |= SEARCH_RETURN_MODSEQ;
-		client_enable(ctx->cmd->client, MAILBOX_FEATURE_CONDSTORE);
-	}
-
-	ctx->box = ctx->cmd->client->mailbox;
-	ctx->trans = mailbox_transaction_begin(ctx->box, 0);
-	ctx->sargs = sargs;
-	ctx->search_ctx = mailbox_search_init(ctx->trans, sargs, NULL);
-	ctx->mail = mail_alloc(ctx->trans, 0, NULL);
-	(void)gettimeofday(&ctx->start_time, NULL);
-	i_array_init(&ctx->result, 128);
-	if ((ctx->return_options & SEARCH_RETURN_UPDATE) != 0)


More information about the dovecot-cvs mailing list