* Fixed db_obj_get not handling deleted nodes correctly. (bugreport:999)
git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12217 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
419106681a
commit
1c3f5fe7e4
@ -3,6 +3,8 @@ Date Added
|
|||||||
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
|
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
|
||||||
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||||
|
|
||||||
|
2007/02/19
|
||||||
|
* Fixed db_obj_get not handling deleted nodes correctly. (bugreport:999) [FlavioJS]
|
||||||
2008/02/17
|
2008/02/17
|
||||||
* corrected login_fd/char_fd being uninitialized in the char servers.
|
* corrected login_fd/char_fd being uninitialized in the char servers.
|
||||||
* Added a check to prevent using consume-delay items when you cannot use
|
* Added a check to prevent using consume-delay items when you cannot use
|
||||||
|
@ -48,12 +48,12 @@
|
|||||||
* - create a db that organizes itself by splaying
|
* - create a db that organizes itself by splaying
|
||||||
*
|
*
|
||||||
* HISTORY:
|
* HISTORY:
|
||||||
|
* 2008/02/19 - Fixed db_obj_get not handling deleted entries correctly.
|
||||||
* 2007/11/09 - Added an iterator to the database.
|
* 2007/11/09 - Added an iterator to the database.
|
||||||
* 2006/12/21 - Added 1-node cache to the database.
|
* 2006/12/21 - Added 1-node cache to the database.
|
||||||
* 2.1 (Athena build #???#) - Portability fix
|
* 2.1 (Athena build #???#) - Portability fix
|
||||||
* - Fixed the portability of casting to union and added the functions
|
* - Fixed the portability of casting to union and added the functions
|
||||||
* {@link DB#ensure(DB,DBKey,DBCreateData,...)} and
|
* ensure and clear to the database.
|
||||||
* {@link DB#clear(DB,DBApply,...)}.
|
|
||||||
* 2.0 (Athena build 4859) - Transition version
|
* 2.0 (Athena build 4859) - Transition version
|
||||||
* - Almost everything recoded with a strategy similar to objects,
|
* - Almost everything recoded with a strategy similar to objects,
|
||||||
* database structure is maintained.
|
* database structure is maintained.
|
||||||
@ -627,7 +627,7 @@ static DBKey db_dup_key(DBMap_impl* db, DBKey key)
|
|||||||
case DB_ISTRING:
|
case DB_ISTRING:
|
||||||
if (db->maxlen) {
|
if (db->maxlen) {
|
||||||
CREATE(str, char, db->maxlen +1);
|
CREATE(str, char, db->maxlen +1);
|
||||||
memcpy(str, key.str, db->maxlen);
|
strncpy(str, key.str, db->maxlen);
|
||||||
str[db->maxlen] = '\0';
|
str[db->maxlen] = '\0';
|
||||||
key.str = str;
|
key.str = str;
|
||||||
} else {
|
} else {
|
||||||
@ -1282,7 +1282,7 @@ void* dbit_obj_prev(DBIterator* self, DBKey* out_key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( !node->deleted )
|
if( !node->deleted )
|
||||||
{// found next entry
|
{// found previous entry
|
||||||
it->node = node;
|
it->node = node;
|
||||||
if( out_key )
|
if( out_key )
|
||||||
memcpy(out_key, &node->key, sizeof(DBKey));
|
memcpy(out_key, &node->key, sizeof(DBKey));
|
||||||
@ -1413,15 +1413,25 @@ static void* db_obj_get(DBMap* self, DBKey key)
|
|||||||
return NULL; // nullpo candidate
|
return NULL; // nullpo candidate
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db->cache && db->cmp(key, db->cache->key, db->maxlen) == 0)
|
if (db->cache && db->cmp(key, db->cache->key, db->maxlen) == 0) {
|
||||||
|
#if defined(DEBUG)
|
||||||
|
if (db->cache->deleted) {
|
||||||
|
ShowDebug("db_get: Cache contains a deleted node. Please report this!!!\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return db->cache->data; // cache hit
|
return db->cache->data; // cache hit
|
||||||
|
}
|
||||||
|
|
||||||
db_free_lock(db);
|
db_free_lock(db);
|
||||||
node = db->ht[db->hash(key, db->maxlen)%HASH_SIZE];
|
node = db->ht[db->hash(key, db->maxlen)%HASH_SIZE];
|
||||||
while (node) {
|
while (node) {
|
||||||
c = db->cmp(key, node->key, db->maxlen);
|
c = db->cmp(key, node->key, db->maxlen);
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
data = node->data;
|
if (!(node->deleted)) {
|
||||||
|
data = node->data;
|
||||||
|
db->cache = node;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
@ -1429,7 +1439,6 @@ static void* db_obj_get(DBMap* self, DBKey key)
|
|||||||
else
|
else
|
||||||
node = node->right;
|
node = node->right;
|
||||||
}
|
}
|
||||||
db->cache = node;
|
|
||||||
db_free_unlock(db);
|
db_free_unlock(db);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -1865,7 +1874,7 @@ static int db_obj_vforeach(DBMap* self, DBApply func, va_list args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just calls {@link common\db.h\DB#vforeach(DB,DBApply,va_list)}.
|
* Just calls {@link DBMap#vforeach}.
|
||||||
* Apply <code>func</code> to every entry in the database.
|
* Apply <code>func</code> to every entry in the database.
|
||||||
* Returns the sum of values returned by func.
|
* Returns the sum of values returned by func.
|
||||||
* @param self Interface of the database
|
* @param self Interface of the database
|
||||||
|
Loading…
x
Reference in New Issue
Block a user