packagefs: AttributeIndex: Support duplicates correctly
The tree comparisons didn't allow for different Nodes having the same attribute value. Therefore only the first node would be added and later we would try to remove a node not actually in the tree, leading to a crash. packagefs seems to finally unmount cleanly, now.
This commit is contained in:
parent
05940bc514
commit
ce577d8db0
@ -89,14 +89,29 @@ struct AttributeIndex::TreeDefinition {
|
||||
|
||||
int Compare(const Key& a, const Value* b) const
|
||||
{
|
||||
return QueryParser::compareKeys(fType, a.data, a.length, b->data,
|
||||
int cmp = QueryParser::compareKeys(fType, a.data, a.length, b->data,
|
||||
b->length);
|
||||
if (cmp != 0)
|
||||
return cmp;
|
||||
|
||||
// The attribute value is the same. Since the tree value is the tree
|
||||
// node itself, we must not return 0, though. We consider a node-less
|
||||
// key always less than an actual tree node with the same attribute
|
||||
// value.
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Compare(const Value* a, const Value* b) const
|
||||
{
|
||||
return QueryParser::compareKeys(fType, a->data, a->length, b->data,
|
||||
if (a == b)
|
||||
return 0;
|
||||
|
||||
int cmp = QueryParser::compareKeys(fType, a->data, a->length, b->data,
|
||||
b->length);
|
||||
if (cmp != 0)
|
||||
return cmp;
|
||||
|
||||
return a < b ? -1 : 1;
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user