[dovecot-cvs] dovecot/src/lib-storage/index index-mail-headers.c, 1.21, 1.22 index-mail.c, 1.38, 1.39 index-mail.h, 1.13, 1.14 index-transaction.c, 1.6, 1.7

cras at procontrol.fi cras at procontrol.fi
Sun Jul 4 23:00:50 EEST 2004


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

Modified Files:
	index-mail-headers.c index-mail.c index-mail.h 
	index-transaction.c 
Log Message:
Cache updating is done now by first reserving space where to write, and then
writing to it whenever buffer gets full. There is no persistent cache file
locks anymore because of this, but it also means that the same cached field
may be written multiple times to the file by different processes. Also since
we reserve more space than we actually need at first, it some space can be
wasted if multiple processes are updating the cache.



Index: index-mail-headers.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-mail-headers.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- index-mail-headers.c	4 Jul 2004 14:26:23 -0000	1.21
+++ index-mail-headers.c	4 Jul 2004 20:00:47 -0000	1.22
@@ -394,9 +394,7 @@
 	/* FIXME: add some smart checks here. we don't necessarily want to
 	   cache everything.. */
 
-	if (!index_mail_cache_transaction_begin(mail))
-		return FALSE;
-
+	index_mail_cache_transaction_begin(mail);
 	return TRUE;
 }
 

Index: index-mail.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-mail.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- index-mail.c	4 Jul 2004 11:50:49 -0000	1.38
+++ index-mail.c	4 Jul 2004 20:00:47 -0000	1.39
@@ -123,26 +123,13 @@
 	}
 }
 
-int index_mail_cache_transaction_begin(struct index_mail *mail)
+void index_mail_cache_transaction_begin(struct index_mail *mail)
 {
-	if (mail->trans->cache_trans != NULL)
-		return TRUE;
-
-	if (mail->trans->cache_trans_failed) {
-		/* don't try more than once */
-		return FALSE;
-	}
-
-	if (mail_cache_transaction_begin(mail->trans->cache_view, TRUE,
-					 mail->trans->trans,
-					 &mail->trans->cache_trans) <= 0) {
-                mail->trans->cache_trans_failed = TRUE;
-		return FALSE;
+	if (mail->trans->cache_trans == NULL) {
+		mail->trans->cache_trans =
+			mail_cache_get_transaction(mail->trans->cache_view,
+						   mail->trans->trans);
 	}
-
-	mail->data.cached_fields =
-		mail_cache_get_fields(mail->trans->cache_view, mail->data.seq);
-	return TRUE;
 }
 
 static int index_mail_cache_can_add(struct index_mail *mail,
@@ -153,8 +140,7 @@
 
 	// FIXME: check if we really want to cache this
 
-	if (!index_mail_cache_transaction_begin(mail))
-		return FALSE;
+	index_mail_cache_transaction_begin(mail);
 
 	/* cached_fields may have changed, recheck */
 	if ((mail->data.cached_fields & field) != 0)
@@ -169,9 +155,8 @@
         if (!index_mail_cache_can_add(mail, field))
 		return;
 
-	if (mail_cache_add(mail->trans->cache_trans, mail->data.seq,
-			   field, data, size) < 0)
-		mail_cache_transaction_rollback(mail->trans->cache_trans);
+	mail_cache_add(mail->trans->cache_trans, mail->data.seq,
+		       field, data, size);
 
 	mail->data.cached_fields |= field;
 }
@@ -359,8 +344,7 @@
 		mail->mail.has_no_nuls = TRUE;
 	}
 
-	if (!index_mail_cache_transaction_begin(mail))
-		return;
+	index_mail_cache_transaction_begin(mail);
 
 	/* update cache_flags */
 	cache_flags = mail_cache_get_record_flags(mail->trans->cache_view,

Index: index-mail.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-mail.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- index-mail.h	23 Jun 2004 18:33:22 -0000	1.13
+++ index-mail.h	4 Jul 2004 20:00:47 -0000	1.14
@@ -79,7 +79,7 @@
 			    struct message_header_line *hdr,
 			    struct index_mail *mail);
 
-int index_mail_cache_transaction_begin(struct index_mail *mail);
+void index_mail_cache_transaction_begin(struct index_mail *mail);
 void index_mail_cache_add(struct index_mail *mail, enum mail_cache_field field,
 			  const void *data, size_t size);
 

Index: index-transaction.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-transaction.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- index-transaction.c	4 Jul 2004 14:26:23 -0000	1.6
+++ index-transaction.c	4 Jul 2004 20:00:47 -0000	1.7
@@ -15,9 +15,6 @@
 
 static void index_transaction_free(struct index_transaction_context *t)
 {
-	if (t->cache_trans != NULL)
-		mail_cache_transaction_end(t->cache_trans);
-
 	mail_cache_view_close(t->cache_view);
 	mail_index_view_close(t->trans_view);
 	mail_index_view_unlock(t->ibox->view);
@@ -35,9 +32,6 @@
 	uoff_t offset;
 	int ret;
 
-	if (t->cache_trans != NULL)
-		(void)mail_cache_transaction_commit(t->cache_trans);
-
 	ret = mail_index_transaction_commit(t->trans, &seq, &offset);
 	if (ret < 0)
 		mail_storage_set_index_error(t->ibox);



More information about the dovecot-cvs mailing list