X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=rculfhash.c;h=fa2121c9820edaa010856bf96a675a9cd6eace2e;hb=d2be3620f8040e68c0abdfb6ee9f11cc8b0961bc;hp=93514d429a5d4fe242fec8b102288101e9a1d78f;hpb=59290e9dc90ce01920f1a18a8699dd6872c45ffc;p=urcu.git diff --git a/rculfhash.c b/rculfhash.c index 93514d4..fa2121c 100644 --- a/rculfhash.c +++ b/rculfhash.c @@ -1651,6 +1651,9 @@ void _do_cds_lfht_resize(struct cds_lfht *ht) * Resize table, re-do if the target size has changed under us. */ do { + assert(uatomic_read(&ht->in_progress_resize)); + if (CMM_LOAD_SHARED(ht->in_progress_destroy)) + break; ht->t.resize_initiated = 1; old_size = ht->t.size; new_size = CMM_LOAD_SHARED(ht->t.resize_target); @@ -1720,8 +1723,10 @@ void cds_lfht_resize_lazy(struct cds_lfht *ht, unsigned long size, int growth) if (!CMM_LOAD_SHARED(ht->t.resize_initiated) && size < target_size) { uatomic_inc(&ht->in_progress_resize); cmm_smp_mb(); /* increment resize count before load destroy */ - if (CMM_LOAD_SHARED(ht->in_progress_destroy)) + if (CMM_LOAD_SHARED(ht->in_progress_destroy)) { + uatomic_dec(&ht->in_progress_resize); return; + } work = malloc(sizeof(*work)); work->ht = ht; ht->cds_lfht_call_rcu(&work->head, do_resize_cb); @@ -1745,8 +1750,10 @@ void cds_lfht_resize_lazy_count(struct cds_lfht *ht, unsigned long size, if (!CMM_LOAD_SHARED(ht->t.resize_initiated)) { uatomic_inc(&ht->in_progress_resize); cmm_smp_mb(); /* increment resize count before load destroy */ - if (CMM_LOAD_SHARED(ht->in_progress_destroy)) + if (CMM_LOAD_SHARED(ht->in_progress_destroy)) { + uatomic_dec(&ht->in_progress_resize); return; + } work = malloc(sizeof(*work)); work->ht = ht; ht->cds_lfht_call_rcu(&work->head, do_resize_cb);