[dovecot-cvs] dovecot/src/lib-storage mail-storage-private.h, 1.5, 1.6 mail-storage.c, 1.26, 1.27 mail-storage.h, 1.72, 1.73 proxy-mail.c, 1.4, 1.5 proxy-mailbox.c, 1.8, 1.9

cras at dovecot.org cras at dovecot.org
Sun Jul 18 05:25:10 EEST 2004


Update of /home/cvs/dovecot/src/lib-storage
In directory talvi:/tmp/cvs-serv3398/lib-storage

Modified Files:
	mail-storage-private.h mail-storage.c mail-storage.h 
	proxy-mail.c proxy-mailbox.c 
Log Message:
Header caching redesigned. New design allows caching decisions per field, so
they can be divided to temporary/permanent. Cached headers are now always
returned in original order, old code didn't guarantee it. Some other caching
changes. (still missing code to store changes in caching decisions)



Index: mail-storage-private.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/mail-storage-private.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- mail-storage-private.h	12 Jul 2004 11:35:51 -0000	1.5
+++ mail-storage-private.h	18 Jul 2004 02:25:07 -0000	1.6
@@ -89,15 +89,19 @@
 	int (*get_uids)(struct mailbox *box, uint32_t uid1, uint32_t uid2,
 			uint32_t *seq1_r, uint32_t *seq2_r);
 
+	struct mailbox_header_lookup_ctx *
+		(*header_lookup_init)(struct mailbox *box,
+				      const char *const headers[]);
+	void (*header_lookup_deinit)(struct mailbox_header_lookup_ctx *ctx);
+
 	int (*search_get_sorting)(struct mailbox *box,
 				  enum mail_sort_type *sort_program);
 	struct mail_search_context *
-		(*search_init)(struct mailbox_transaction_context *t,
-			       const char *charset,
-			       struct mail_search_arg *args,
-			       const enum mail_sort_type *sort_program,
-			       enum mail_fetch_field wanted_fields,
-			       const char *const wanted_headers[]);
+	(*search_init)(struct mailbox_transaction_context *t,
+		       const char *charset, struct mail_search_arg *args,
+		       const enum mail_sort_type *sort_program,
+		       enum mail_fetch_field wanted_fields,
+		       struct mailbox_header_lookup_ctx *wanted_headers);
 	int (*search_deinit)(struct mail_search_context *ctx);
 	struct mail *(*search_next)(struct mail_search_context *ctx);
 
@@ -128,6 +132,10 @@
 	struct mailbox *box;
 };
 
+struct mailbox_header_lookup_ctx {
+	struct mailbox *box;
+};
+
 /* Set error message in storage. Critical errors are logged with i_error(),
    but user sees only "internal error" message. */
 void mail_storage_clear_error(struct mail_storage *storage);

Index: mail-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/mail-storage.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- mail-storage.c	12 Jul 2004 11:35:51 -0000	1.26
+++ mail-storage.c	18 Jul 2004 02:25:07 -0000	1.27
@@ -370,6 +370,17 @@
 	return box->get_uids(box, uid1, uid2, seq1_r, seq2_r);
 }
 
+struct mailbox_header_lookup_ctx *
+mailbox_header_lookup_init(struct mailbox *box, const char *const headers[])
+{
+	return box->header_lookup_init(box, headers);
+}
+
+void mailbox_header_lookup_deinit(struct mailbox_header_lookup_ctx *ctx)
+{
+	ctx->box->header_lookup_deinit(ctx);
+}
+
 int mailbox_search_get_sorting(struct mailbox *box,
 			       enum mail_sort_type *sort_program)
 {
@@ -381,7 +392,7 @@
 		    const char *charset, struct mail_search_arg *args,
 		    const enum mail_sort_type *sort_program,
 		    enum mail_fetch_field wanted_fields,
-		    const char *const wanted_headers[])
+		    struct mailbox_header_lookup_ctx *wanted_headers)
 {
 	return t->box->search_init(t, charset, args, sort_program,
 				   wanted_fields, wanted_headers);

Index: mail-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/mail-storage.h,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- mail-storage.h	12 Jul 2004 11:35:51 -0000	1.72
+++ mail-storage.h	18 Jul 2004 02:25:07 -0000	1.73
@@ -289,6 +289,11 @@
 int mailbox_get_uids(struct mailbox *box, uint32_t uid1, uint32_t uid2,
 		     uint32_t *seq1_r, uint32_t *seq2_r);
 
+/* Initialize header lookup for given headers. */
+struct mailbox_header_lookup_ctx *
+mailbox_header_lookup_init(struct mailbox *box, const char *const headers[]);
+void mailbox_header_lookup_deinit(struct mailbox_header_lookup_ctx *ctx);
+
 /* Modify sort_program to specify a sort program acceptable for
    search_init(). If mailbox supports no sorting, it's simply set to
    {MAIL_SORT_END}. */
@@ -308,7 +313,7 @@
 		    const char *charset, struct mail_search_arg *args,
 		    const enum mail_sort_type *sort_program,
 		    enum mail_fetch_field wanted_fields,
-		    const char *const wanted_headers[]);
+                    struct mailbox_header_lookup_ctx *wanted_headers);
 /* Deinitialize search request. */
 int mailbox_search_deinit(struct mail_search_context *ctx);
 /* Search the next message. Returned mail object can be used until
@@ -365,10 +370,10 @@
 
 	/* Get value for single header field */
 	const char *(*get_header)(struct mail *mail, const char *field);
-	/* Returns partial headers which contain _at least_ the given fields,
-	   but it may contain others as well. */
-	struct istream *(*get_headers)(struct mail *mail,
-				       const char *const minimum_fields[]);
+	/* Returns stream containing specified headers. */
+	struct istream *
+		(*get_headers)(struct mail *mail,
+			       struct mailbox_header_lookup_ctx *headers);
 
 	/* Returns input stream pointing to beginning of message header.
 	   hdr_size and body_size are updated unless they're NULL. */
@@ -376,7 +381,7 @@
 				      struct message_size *hdr_size,
 				      struct message_size *body_size);
 
-	/* Get the any of the "special" fields. */
+	/* Get any of the "special" fields. */
 	const char *(*get_special)(struct mail *mail,
 				   enum mail_fetch_field field);
 

Index: proxy-mail.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/proxy-mail.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- proxy-mail.c	27 Apr 2004 20:25:54 -0000	1.4
+++ proxy-mail.c	18 Jul 2004 02:25:07 -0000	1.5
@@ -45,6 +45,14 @@
 	return p->mail->get_header(p->mail, field);
 }
 
+static struct istream *
+_get_headers(struct mail *mail, struct mailbox_header_lookup_ctx *headers)
+{
+	struct proxy_mail *p = (struct proxy_mail *) mail;
+
+	return p->mail->get_headers(p->mail, headers);
+}
+
 static struct istream *_get_stream(struct mail *mail,
 				   struct message_size *hdr_size,
 				   struct message_size *body_size)
@@ -91,6 +99,7 @@
 	pm->get_date = _get_date;
 	pm->get_size = _get_size;
 	pm->get_header = _get_header;
+	pm->get_headers = _get_headers;
 	pm->get_stream = _get_stream;
 	pm->get_special = _get_special;
 	pm->update_flags = _update_flags;

Index: proxy-mailbox.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/proxy-mailbox.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- proxy-mailbox.c	12 Jul 2004 11:35:51 -0000	1.8
+++ proxy-mailbox.c	18 Jul 2004 02:25:07 -0000	1.9
@@ -66,6 +66,14 @@
 	return p->box->get_uids(p->box, uid1, uid2, seq1_r, seq2_r);
 }
 
+static struct mailbox_header_lookup_ctx *
+_header_lookup_init(struct mailbox *box, const char *const headers[])
+{
+	struct proxy_mailbox *p = (struct proxy_mailbox *) box;
+
+	return p->box->header_lookup_init(p->box, headers);
+}
+
 static int _search_get_sorting(struct mailbox *box,
 			       enum mail_sort_type *sort_program)
 {
@@ -79,7 +87,7 @@
 	     const char *charset, struct mail_search_arg *args,
 	     const enum mail_sort_type *sort_program,
 	     enum mail_fetch_field wanted_fields,
-	     const char *const wanted_headers[])
+	     struct mailbox_header_lookup_ctx *wanted_headers)
 {
 	struct proxy_mailbox_transaction_context *pt =
 		(struct proxy_mailbox_transaction_context *)t;
@@ -157,6 +165,7 @@
 	pb->notify_changes = _notify_changes;
 	pb->fetch = _fetch;
 	pb->get_uids = _get_uids;
+	pb->header_lookup_init = _header_lookup_init;
 
 	pb->search_get_sorting = _search_get_sorting;
 	pb->search_init = _search_init;



More information about the dovecot-cvs mailing list