Nptr dataNode;
dataT data;
- slot = findKey(B, findNode, 1, numentries(findNode));
+ slot = getSlot(B, findNode);
+ if (slot <= BTERROR)
+ return NONODE;
+
dataNode = getnode(findNode, slot);
data = getdatavalue(dataNode);
memset(prev, 0, sizeof(prev));
- for (depth = 0, slot = getSlot(B, curr); isinternal(curr); depth++, slot = getSlot(B, curr)) {
+ for (depth = 0, slot = getSlot(B, curr); (slot >= 0) && isinternal(curr); depth++, slot = getSlot(B, curr)) {
prev[depth] = curr;
if (slot == 0)
curr = getfirstnode(curr);
- else
+ else if (slot > 0)
curr = getnode(curr, slot);
+ else /* BTERROR */ {
+ curr = NONODE;
+ break;
+ }
#ifdef DEBUG_BTREE
if ( !isnode(curr) )
DebugBreak();
int diff, comp, findslot;
diff = comparekeys(B)(getfunkey(B), getkey(curr, slot), 0);
+ if (diff == 0) {
+ findslot = slot;
+ } else
if (diff < 0) { /* also check previous slot */
if ((slot == 1) ||
((comp = comparekeys(B)(getfunkey(B), getkey(curr, slot - 1), 0)) >= 0))
setsplitpath(B, curr); /* indicates where nodes must split */
slot = getSlot(B, curr); /* is null only if the root is empty */
+ if (slot <= BTERROR)
+ return NONODE;
if (isinternal(curr)) { /* continue recursion to leaves */
if (slot == 0)
downNode = descendSplit(B, getfirstnode(curr));
setmergepath(B, curr); /* mark which nodes may need rebalancing */
slot = getSlot(B, curr);
+ if (slot <= BTERROR)
+ return NONODE;
if (isinternal(curr)) /* set up next recursion call's parameters */
{
#endif
setfunkey(B, getkey(right, 1)); /* defined but maybe just deleted */
z = getSlot(B, anchor); /* needs the just calculated key */
+ if (z <= BTERROR)
+ return NONODE;
setfunkey(B, getkey(anchor, z)); /* set slot to delete in anchor */
setentry(left, numentries(left), getfunkey(B), getfirstnode(right));
}
x = numentries(left) + y;
setfunkey(B, getkey(right, y + 1 - i)); /* set new anchor key value */
z = getSlot(B, anchor); /* find slot in anchor node */
+ if (z <= BTERROR)
+ return NONODE;
#ifdef DEBUG_BTREE
if (z == 0 && !isroot(anchor))
DebugBreak();
setfunkey(B, getkey(left, x)); /* set new anchor key value */
z = getSlot(B, anchor) + 1;
+ if (z <= BTERROR)
+ return NONODE;
if (i) {
decentries(left);
incentries(right);
/*
* the return must be -1, 0, or 1. stricmp() in MSVC 8.0
* does not return only those values.
+ *
+ * the sorting of the tree is by case insensitive sort order
+ * therefore, unless the strings actually match via a case
+ * insensitive search do we want to perform the case sensitive
+ * match. Otherwise, the search order might be considered
+ * to be inconsistent when the EXACT_MATCH flag is set.
*/
static int
compareKeys(keyT key1, keyT key2, int flags)
{
int comp;
- if (flags & EXACT_MATCH)
+ comp = stricmp(key1.name, key2.name);
+ if (comp == 0 && (flags & EXACT_MATCH))
comp = strcmp(key1.name, key2.name);
- else
- comp = stricmp(key1.name, key2.name);
return (comp < 0 ? -1 : (comp > 0 ? 1 : 0));
}
goto done;
}
+ lock_AssertAny(&op->scp->dirlock);
+
QueryPerformanceCounter(&start);
leafNode = bplus_Lookup(op->scp->dirBplus, key);
* If we have an ambiguous match, return an error.
* If we have only one inexact match, return that.
*/
- slot = findKey(op->scp->dirBplus, leafNode, 1, numentries(leafNode));
+ slot = getSlot(op->scp->dirBplus, leafNode);
+ if (slot <= BTERROR) {
+ op->scp->dirDataVersion = 0;
+ rc = EINVAL;
+ goto done;
+ }
firstDataNode = getnode(leafNode, slot);
for ( dataNode = firstDataNode; dataNode; dataNode = nextDataNode) {
goto done;
}
+
+ lock_AssertWrite(&op->scp->dirlock);
+
data.fid.cell = cfid->cell;
data.fid.volume = cfid->volume;
data.fid.vnode = cfid->vnode;
goto done;
}
+ lock_AssertWrite(&op->scp->dirlock);
+
QueryPerformanceCounter(&start);
bplus_remove_entry++;
* If we have an ambiguous match, return an error.
* If we have only one inexact match, return that.
*/
- slot = findKey(op->scp->dirBplus, leafNode, 1, numentries(leafNode));
+ slot = getSlot(op->scp->dirBplus, leafNode);
+ if (slot <= BTERROR) {
+ op->scp->dirDataVersion = 0;
+ rc = EINVAL;
+ goto done;
+ }
firstDataNode = getnode(leafNode, slot);
for ( dataNode = firstDataNode; dataNode; dataNode = nextDataNode) {
* If we have an ambiguous match, return an error.
* If we have only one inexact match, return that.
*/
- slot = findKey(op->scp->dirBplus, leafNode, 1, numentries(leafNode));
+ slot = getSlot(op->scp->dirBplus, leafNode);
+ if (slot <= BTERROR) {
+ op->scp->dirDataVersion = 0;
+ rc = EINVAL;
+ goto done;
+
+ }
firstDataNode = getnode(leafNode, slot);
for ( dataNode = firstDataNode; dataNode; dataNode = nextDataNode) {
}
if (rc != CM_ERROR_AMBIGUOUS_FILENAME) {
- if (longname) {
- key.name = longname;
- delete(op->scp->dirBplus, key);
- key.name = entry;
- }
+ if (longname) {
+ key.name = longname;
+ delete(op->scp->dirBplus, key);
+ key.name = entry;
+ }
delete(op->scp->dirBplus, key);
}
}
osi_assert(scp->dirBplus == NULL);
+ lock_AssertWrite(&scp->dirlock);
+
QueryPerformanceCounter(&start);
bplus_build_tree++;