0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

fix hashtable so that deleted entries don't prevent finding later chained entries SERVER-553

This commit is contained in:
Eliot Horowitz 2010-01-19 10:58:35 -05:00
parent 14a0217520
commit 693b5980dc

View File

@ -61,11 +61,16 @@ namespace mongo {
int i = h % n;
int start = i;
int chain = 0;
int firstNonUsed = -1;
while ( 1 ) {
if ( !nodes[i].inUse() ) {
return i;
if ( firstNonUsed < 0 )
firstNonUsed = i;
}
if ( nodes[i].hash == h && nodes[i].k == k ) {
if ( chain >= 200 )
out() << "warning: hashtable " << name << " long chain " << endl;
found = true;
return i;
}
@ -77,11 +82,11 @@ namespace mongo {
return -1;
}
if( chain >= maxChain ) {
if ( firstNonUsed >= 0 )
return firstNonUsed;
out() << "error: hashtable " << name << " max chain n:" << n << endl;
return -1;
}
if ( chain == 200 )
out() << "warning: hashtable " << name << " long chain " << endl;
}
}
@ -112,7 +117,7 @@ namespace mongo {
bool found;
int i = _find(k, found);
if ( i >= 0 && found ) {
//TEMP nodes[i].k.kill();
nodes[i].k.kill();
nodes[i].setUnused();
}
}