# HG changeset patch # User Timo Sirainen # Date 1033868136 -10800 # Node ID 9fd132e47845ce7f6aa19a6e999cd49709becb70 # Parent cf4b8f204aeaa09dcb013c4ea1afcf067da27b48 bugfixes diff -r cf4b8f204aea -r 9fd132e47845 src/lib-index/mail-tree-redblack.c --- 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 */ diff -r cf4b8f204aea -r 9fd132e47845 src/lib-index/mail-tree.c --- 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)