changeset 359:9fd132e47845 HEAD

bugfixes
author Timo Sirainen <tss@iki.fi>
date Sun, 06 Oct 2002 04:35:36 +0300
parents cf4b8f204aea
children d57e5037db2c
files src/lib-index/mail-tree-redblack.c src/lib-index/mail-tree.c
diffstat 2 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-tree-redblack.c	Sun Oct 06 04:10:51 2002 +0300
+++ b/src/lib-index/mail-tree-redblack.c	Sun Oct 06 04:35:36 2002 +0300
@@ -446,8 +446,9 @@
 	else
 		x = node[y].right;
 
-	if (x != RBNULL)
-		node[x].up = node[y].up;
+	/* this may modify RBNULL, which IMHO is a bit nasty,
+	   but rb_delete_fix() requires it to work properly. */
+	node[x].up = node[y].up;
 
 	if (node[y].up == RBNULL) {
 		tree->header->root = x;
@@ -685,7 +686,7 @@
 		if (seq < left_nodes)
 			x = node[x].left;
 		else if (seq > left_nodes) {
-			upleft_nodes = left_nodes;
+			upleft_nodes = left_nodes+1;
 			x = node[x].right;
 		} else {
 			/* found it */
--- a/src/lib-index/mail-tree.c	Sun Oct 06 04:10:51 2002 +0300
+++ b/src/lib-index/mail-tree.c	Sun Oct 06 04:35:36 2002 +0300
@@ -21,7 +21,7 @@
 {
 	i_assert(function != NULL);
 
-	index_set_error(tree->index, "%s failed with tree file %s: %m",
+	index_set_error(tree->index, "%s failed with binary tree file %s: %m",
 			function, tree->filepath);
 	return FALSE;
 }
@@ -33,7 +33,7 @@
 	va_start(va, fmt);
 	t_push();
 
-	index_set_error(tree->index, "Corrupted tree file %s: %s",
+	index_set_error(tree->index, "Corrupted binary tree file %s: %s",
 			tree->filepath, t_strdup_vprintf(fmt, va));
 
 	t_pop();
@@ -86,7 +86,7 @@
 
 	if (tree->mmap_full_length <
 	    sizeof(MailTreeHeader) + sizeof(MailTreeNode)) {
-		index_set_error(tree->index, "Too small tree file %s",
+		index_set_error(tree->index, "Too small binary tree file %s",
 				tree->filepath);
 		(void)unlink(tree->filepath);
 		return FALSE;
@@ -246,6 +246,9 @@
 	hdr.indexid = tree->index->indexid;
 	hdr.used_file_size = sizeof(MailTreeHeader) + sizeof(MailTreeNode);
 
+	if (lseek(tree->fd, 0, SEEK_SET) < 0)
+		return tree_set_syscall_error(tree, "lseek()");
+
 	if (write_full(tree->fd, &hdr, sizeof(hdr)) < 0) {
 		if (errno == ENOSPC)
 			tree->index->nodiskspace = TRUE;
@@ -261,7 +264,6 @@
 	}
 
 	return TRUE;
-
 }
 
 int mail_tree_rebuild(MailTree *tree)