X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=rculfhash.c;h=f3c96880fc6dc12c920a204bf284be14f688c16c;hb=33c7c748c098dfc963c934fde62328169834c1ed;hp=6941ec189df941ca7fe71616d50d57c2dc8b8aa5;hpb=01370f0b44f53c26c5a1b9387a94ac37f89bc289;p=urcu.git diff --git a/rculfhash.c b/rculfhash.c index 6941ec1..f3c9688 100644 --- a/rculfhash.c +++ b/rculfhash.c @@ -76,7 +76,7 @@ struct rcu_ht { ht_compare_fct compare_fct; unsigned long hash_seed; pthread_mutex_t resize_mutex; /* resize mutex: add/del mutex */ - unsigned int in_progress_resize; + unsigned int in_progress_resize, in_progress_destroy; void (*ht_call_rcu)(struct rcu_head *head, void (*func)(struct rcu_head *head)); }; @@ -525,10 +525,14 @@ void init_table(struct rcu_ht *ht, struct rcu_table *t, new_node->p.reverse_hash = bit_reverse_ulong(!i ? 0 : (1UL << (i - 1)) + j); (void) _ht_add(ht, t, new_node, 0, 1); + if (CMM_LOAD_SHARED(ht->in_progress_destroy)) + break; } /* Update table size */ t->size = !i ? 1 : (1UL << i); dbg_printf("rculfhash: init new size: %lu\n", t->size); + if (CMM_LOAD_SHARED(ht->in_progress_destroy)) + break; } t->resize_target = t->size; t->resize_initiated = 0; @@ -673,6 +677,7 @@ int ht_destroy(struct rcu_ht *ht) int ret; /* Wait for in-flight resize operations to complete */ + CMM_STORE_SHARED(ht->in_progress_destroy, 1); while (uatomic_read(&ht->in_progress_resize)) poll(NULL, 0, 100); /* wait for 100ms */ ret = ht_delete_dummy(ht); @@ -736,8 +741,8 @@ void _do_ht_resize(struct rcu_ht *ht) if (old_size == new_size) return; new_order = get_count_order_ulong(new_size) + 1; - dbg_printf("rculfhash: resize from %lu (order %lu) to %lu (order %lu) buckets\n", - old_size, old_order, new_size, new_order); + printf("rculfhash: resize from %lu (order %lu) to %lu (order %lu) buckets\n", + old_size, old_order, new_size, new_order); new_t = malloc(sizeof(struct rcu_table) + (new_order * sizeof(struct _rcu_ht_node *))); assert(new_size > old_size);