[dovecot-cvs] dovecot/src/lib-index mail-cache-transaction.c, 1.20, 1.21

cras at dovecot.org cras at dovecot.org
Fri Sep 10 13:03:10 EEST 2004


Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv30976/lib-index

Modified Files:
	mail-cache-transaction.c 
Log Message:
If we detect cache corruption, try to avoid printing tons of "bad file
descriptor" error messages for writes.



Index: mail-cache-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-transaction.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- mail-cache-transaction.c	15 Aug 2004 02:54:47 -0000	1.20
+++ mail-cache-transaction.c	10 Sep 2004 10:03:08 -0000	1.21
@@ -331,6 +331,9 @@
 	size_t size, max_size, seq_idx, seq_limit, seq_count;
 	int commit;
 
+	if (MAIL_CACHE_IS_UNUSABLE(cache))
+		return -1;
+
 	commit = ctx->prev_seq == 0;
 	if (commit) {
 		/* committing, remove the last dummy record */
@@ -447,7 +450,7 @@
 	struct mail_cache *cache = ctx->cache;
 	int ret = 0;
 
-	if (!ctx->changes) {
+	if (!ctx->changes || MAIL_CACHE_IS_UNUSABLE(cache)) {
 		mail_cache_transaction_free(ctx);
 		return 0;
 	}
@@ -484,7 +487,8 @@
 	i_assert(size % sizeof(uint32_t)*2 == 0);
 	size /= sizeof(*buf);
 
-	if (ctx->reserved_space > 0 || size > 0) {
+	if ((ctx->reserved_space > 0 || size > 0) &&
+	    !MAIL_CACHE_IS_UNUSABLE(cache)) {
 		if (mail_cache_lock(cache) > 0) {
 			mail_cache_transaction_free_space(ctx);
 
@@ -645,6 +649,9 @@
 {
 	i_assert(cache->locked);
 
+	if (MAIL_CACHE_IS_UNUSABLE(cache))
+		return -1;
+
 	if (new_offset + sizeof(struct mail_cache_record) >
 	    cache->hdr_copy.used_file_size) {
 		mail_cache_set_corrupted(cache,



More information about the dovecot-cvs mailing list