Skip to content

Commit f4373a3

Browse files
author
greatriver
committed
Fix hash bug
1 parent 43454fc commit f4373a3

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

source/hdtd/store.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ hd_store_item(hd_context *ctx, void *key, void *val_, size_t itemsize, const hd_
277277
hd_try(ctx)
278278
{
279279
/* May drop and retake the lock */
280-
existing = hd_hash_insert(ctx, store->hash, hash.u.pi.i + hash.u.pi.ptr, item);
280+
existing = hd_hash_insert(ctx, store->hash, &hash, item);
281281
}
282282
hd_catch(ctx)
283283
{
@@ -356,10 +356,7 @@ hd_find_item(hd_context *ctx, hd_store_drop_fn *drop, void *key, const hd_store_
356356
hd_store *store = ctx->store;
357357
hd_store_hash hash = { NULL };
358358

359-
hd_store_hash check_hash = { NULL };
360-
361359
int use_hash = 0;
362-
int use_check_hash = 0;
363360

364361
if (!store)
365362
return NULL;
@@ -376,7 +373,7 @@ hd_find_item(hd_context *ctx, hd_store_drop_fn *drop, void *key, const hd_store_
376373
if (use_hash)
377374
{
378375
/* We can find objects keyed on indirected objects quickly */
379-
item = hd_hash_find(ctx, store->hash, hash.u.pi.i + hash.u.pi.ptr);
376+
item = hd_hash_find(ctx, store->hash, &hash);
380377
}
381378
else
382379
{
@@ -389,14 +386,6 @@ hd_find_item(hd_context *ctx, hd_store_drop_fn *drop, void *key, const hd_store_
389386
}
390387
if (item)
391388
{
392-
//Need to check the key is the same
393-
use_check_hash = type->make_hash_key(ctx, &check_hash, item->key);
394-
if (!use_check_hash)
395-
return NULL;
396-
397-
if(hash.u.pi.i + hash.u.pi.ptr != check_hash.u.pi.i + check_hash.u.pi.ptr)
398-
return NULL;
399-
400389
/* LRU the block. This also serves to ensure that any item
401390
* picked up from the hash before it has made it into the
402391
* linked list does not get whipped out again due to the

0 commit comments

Comments
 (0)