X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=tests%2Ftest_urcu_hash.c;h=ba8f9e93c2697e126786c7d16e9cd9e7bc3f339c;hb=273399de2e11da5cfea7b412a4bdd904467e9126;hp=59356568bb2602cedea8c98e847f0a9dfe829862;hpb=732ad076c182b3ad706cd62f8a6694f921e1bb7c;p=urcu.git diff --git a/tests/test_urcu_hash.c b/tests/test_urcu_hash.c index 5935656..ba8f9e9 100644 --- a/tests/test_urcu_hash.c +++ b/tests/test_urcu_hash.c @@ -38,7 +38,7 @@ #endif #define HASH_SIZE 32 -#define RAND_POOL 1000 +#define RAND_POOL 10000 /* Make this big enough to include the POWER5+ L3 cacheline size of 256B */ #define CACHE_LINE_SIZE 4096 @@ -403,11 +403,14 @@ void *thr_writer(void *_count) rcu_read_lock(); ht_node_init(node, (void *)(unsigned long)(rand_r(&rand_lookup) % RAND_POOL), - sizeof(void *), - (void *) 0x42); - ht_add(test_ht, node); + sizeof(void *)); + ret = ht_add_unique(test_ht, node); rcu_read_unlock(); - nr_add++; + if (ret) { + free(node); + nr_addexist++; + } else + nr_add++; } else { /* May delete */ rcu_read_lock(); @@ -591,8 +594,13 @@ int main(int argc, char **argv) tot_writes += count_writer[i]; } ret = ht_destroy(test_ht); - if (ret) - printf("WARNING: nodes left in the hash table upon destroy\n"); + if (ret) { + unsigned long count, removed; + + ht_count_nodes(test_ht, &count, &removed); + printf("WARNING: nodes left in the hash table upon destroy: " + "%lu nodes + %lu logically removed.\n", count, removed); + } printf_verbose("final delete: %d items\n", ret); printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,