changeset 132:4dc5d31e2282 HEAD

mail_hash_rebuild() now tries to lock itself, fixing crash if trying to rebuild hash when opening index
author Timo Sirainen <tss@iki.fi>
date Tue, 03 Sep 2002 23:26:07 +0300
parents 4dd31e34e72f
children 788d8536ee18
files src/lib-index/mail-hash.c
diffstat 1 files changed, 4 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-hash.c	Tue Sep 03 23:15:45 2002 +0300
+++ b/src/lib-index/mail-hash.c	Tue Sep 03 23:26:07 2002 +0300
@@ -137,13 +137,6 @@
 	return mail_hash_rebuild(mail_hash_new(index));
 }
 
-static int mail_hash_lock_and_rebuild(MailHash *hash)
-{
-	if (!hash->index->set_lock(hash->index, MAIL_LOCK_EXCLUSIVE))
-		return FALSE;
-	return mail_hash_rebuild(hash);
-}
-
 int mail_hash_open_or_create(MailIndex *index)
 {
 	MailHash *hash;
@@ -153,7 +146,7 @@
 
 	hash->fd = open(hash->filepath, O_RDWR);
 	if (hash->fd == -1)
-		return mail_hash_lock_and_rebuild(hash);
+		return mail_hash_rebuild(hash);
 
 	if (!mmap_update_real(hash)) {
 		/* mmap() failure is fatal */
@@ -179,7 +172,7 @@
 		hash->mmap_base = NULL;
 		hash->dirty_mmap = TRUE;
 
-		return mail_hash_lock_and_rebuild(hash);
+		return mail_hash_rebuild(hash);
 	}
 
 	return TRUE;
@@ -325,7 +318,8 @@
 	unsigned int hash_size;
 	int fd;
 
-	i_assert(hash->index->lock_type == MAIL_LOCK_EXCLUSIVE);
+	if (!hash->index->set_lock(hash->index, MAIL_LOCK_EXCLUSIVE))
+		return FALSE;
 
 	/* first get the number of messages in index */
 	index_header = hash->index->get_header(hash->index);