[dovecot-cvs] dovecot/src/lib-index mail-index-sync-update.c, 1.28, 1.29 mail-transaction-log.c, 1.40, 1.41

cras at procontrol.fi cras at procontrol.fi
Sun Jun 20 16:02:11 EEST 2004


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

Modified Files:
	mail-index-sync-update.c mail-transaction-log.c 
Log Message:
assert crashfixes



Index: mail-index-sync-update.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-sync-update.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- mail-index-sync-update.c	20 Jun 2004 12:23:27 -0000	1.28
+++ mail-index-sync-update.c	20 Jun 2004 13:02:08 -0000	1.29
@@ -297,13 +297,17 @@
 	struct mail_index_map *map;
 	const struct mail_transaction_header *hdr;
 	const void *data;
-	unsigned int count;
+	unsigned int count, old_lock_id;
 	uint32_t seq, i;
 	uoff_t offset;
 	int ret, had_dirty, skipped;
 
+	/* we'll have to update view->lock_id to avoid mail_index_view_lock()
+	   trying to update the file later. */
+	old_lock_id = view->lock_id;
 	if (mail_index_lock_exclusive(index, &view->lock_id) < 0)
 		return -1;
+	mail_index_unlock(index, old_lock_id);
 
 	/* NOTE: locking may change index->map so make sure assignment
 	   after locking */
@@ -343,8 +347,10 @@
 
 		if ((hdr->type & MAIL_TRANSACTION_APPEND) != 0) {
 			count = hdr->size / index->record_size;
-			if (mail_index_grow(index, view->map, count) < 0)
-				return -1;
+			if (mail_index_grow(index, view->map, count) < 0) {
+				ret = -1;
+				break;
+			}
 		}
 
 		if (mail_transaction_map(index, hdr, data,
@@ -355,8 +361,11 @@
 		}
 	}
 
-	if (ret < 0)
+	if (ret < 0) {
+		/*  */
+		mail_index_view_unlock(view);
 		return -1;
+	}
 
 	i_assert(map->records_count == map->hdr->messages_count);
 	i_assert(view->messages_count == map->hdr->messages_count);

Index: mail-transaction-log.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-transaction-log.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- mail-transaction-log.c	20 Jun 2004 09:34:10 -0000	1.40
+++ mail-transaction-log.c	20 Jun 2004 13:02:08 -0000	1.41
@@ -201,6 +201,9 @@
 {
 	int ret;
 
+	if (lock_type == file->lock_type)
+		return 0;
+
 	if (lock_type == F_UNLCK) {
 		i_assert(file->lock_type != F_UNLCK);
 	} else {



More information about the dovecot-cvs mailing list