[dovecot-cvs] dovecot/src/lib-storage mail-storage-private.h, 1.40, 1.41 mail-storage.c, 1.67, 1.68 mail-storage.h, 1.122, 1.123

tss at dovecot.org tss at dovecot.org
Wed Dec 20 19:23:46 UTC 2006


Update of /var/lib/cvs/dovecot/src/lib-storage
In directory talvi:/tmp/cvs-serv31150/lib-storage

Modified Files:
	mail-storage-private.h mail-storage.c mail-storage.h 
Log Message:
Dovecot is now able to execute multiple commands at the same time.
Practically this means commands: FETCH, LIST, SEARCH and syncing output for
all commands. For example it's possible that doing two FETCH commands at the
same time makes their output mixed together.

Non-blocking SEARCH is done by doing search for 20 mails at a time, and then
checking if another command is pending.

Also added X-CANCEL <tag> command to cancel running commands.



Index: mail-storage-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage-private.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- mail-storage-private.h	6 Dec 2006 15:08:24 -0000	1.40
+++ mail-storage-private.h	20 Dec 2006 19:23:43 -0000	1.41
@@ -129,7 +129,8 @@
 		       const char *charset, struct mail_search_arg *args,
 		       const enum mail_sort_type *sort_program);
 	int (*search_deinit)(struct mail_search_context *ctx);
-	int (*search_next)(struct mail_search_context *ctx, struct mail *mail);
+	int (*search_next_nonblock)(struct mail_search_context *ctx,
+				    struct mail *mail, bool *tryagain_r);
 	/* Internal search function which updates ctx->seq */
 	int (*search_next_update_seq)(struct mail_search_context *ctx);
 
@@ -159,6 +160,8 @@
 /* private: */
 	pool_t pool;
 
+	unsigned int transaction_count;
+
 	/* Module-specific contexts. See mail_storage_module_id. */
 	ARRAY_DEFINE(module_contexts, void);
 

Index: mail-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- mail-storage.c	15 Dec 2006 18:38:19 -0000	1.67
+++ mail-storage.c	20 Dec 2006 19:23:44 -0000	1.68
@@ -541,13 +541,30 @@
 
 int mailbox_search_next(struct mail_search_context *ctx, struct mail *mail)
 {
-	return ctx->transaction->box->v.search_next(ctx, mail);
+	bool tryagain;
+	int ret;
+
+	while ((ret = mailbox_search_next_nonblock(ctx, mail,
+						   &tryagain)) == 0) {
+		if (!tryagain)
+			break;
+	}
+
+	return ret;
+}
+
+int mailbox_search_next_nonblock(struct mail_search_context *ctx,
+				 struct mail *mail, bool *tryagain_r)
+{
+	return ctx->transaction->box->v.
+		search_next_nonblock(ctx, mail, tryagain_r);
 }
 
 struct mailbox_transaction_context *
 mailbox_transaction_begin(struct mailbox *box,
 			  enum mailbox_transaction_flags flags)
 {
+	box->transaction_count++;
 	return box->v.transaction_begin(box, flags);
 }
 
@@ -556,6 +573,8 @@
 {
 	struct mailbox_transaction_context *t = *_t;
 
+	t->box->transaction_count--;
+
 	*_t = NULL;
 	return t->box->v.transaction_commit(t, flags);
 }
@@ -564,10 +583,17 @@
 {
 	struct mailbox_transaction_context *t = *_t;
 
+	t->box->transaction_count--;
+
 	*_t = NULL;
 	t->box->v.transaction_rollback(t);
 }
 
+unsigned int mailbox_transaction_get_count(struct mailbox *box)
+{
+	return box->transaction_count;
+}
+
 int mailbox_save_init(struct mailbox_transaction_context *t,
 		      enum mail_flags flags, struct mail_keywords *keywords,
 		      time_t received_date, int timezone_offset,

Index: mail-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage.h,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- mail-storage.h	15 Dec 2006 18:38:19 -0000	1.122
+++ mail-storage.h	20 Dec 2006 19:23:44 -0000	1.123
@@ -324,6 +324,8 @@
 int mailbox_transaction_commit(struct mailbox_transaction_context **t,
 			       enum mailbox_sync_flags flags);
 void mailbox_transaction_rollback(struct mailbox_transaction_context **t);
+/* Return the number of active transactions for the mailbox. */
+unsigned int mailbox_transaction_get_count(struct mailbox *box);
 
 /* Build mail_keywords from NULL-terminated keywords list. */
 struct mail_keywords *
@@ -352,6 +354,11 @@
 int mailbox_search_deinit(struct mail_search_context **ctx);
 /* Search the next message. Returns 1 if found, 0 if not, -1 if failure. */
 int mailbox_search_next(struct mail_search_context *ctx, struct mail *mail);
+/* Like mailbox_search_next(), but don't spend too much time searching.
+   Returns 1 if found, -1 if failure or 0 with tryagain_r=FALSE if
+   finished, and TRUE if more results will by calling the function again. */
+int mailbox_search_next_nonblock(struct mail_search_context *ctx,
+				 struct mail *mail, bool *tryagain_r);
 
 /* Save a mail into mailbox. timezone_offset specifies the timezone in
    minutes in which received_date was originally given with. To use



More information about the dovecot-cvs mailing list