X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu%2Fstatic%2Frculfstack.h;h=ed6b0d4a6890d7d0f4205106ff5db09627c9f3f1;hp=ba26231e87206371965c653189596137abb818cd;hb=7618919ae496bda84a2efa4f2ad0abe569892a9e;hpb=4a0b347ad068737b5ab0565cd4506f2f3b21e1f2 diff --git a/urcu/static/rculfstack.h b/urcu/static/rculfstack.h index ba26231..ed6b0d4 100644 --- a/urcu/static/rculfstack.h +++ b/urcu/static/rculfstack.h @@ -63,7 +63,7 @@ void _cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s, struct cds_lfs_node_rcu *nod } /* - * Should be called under rcu read-side lock. + * Acts as a RCU reader. * * The caller must wait for a grace period to pass before freeing the returned * node or modifying the cds_lfs_node_rcu structure. @@ -76,18 +76,22 @@ _cds_lfs_pop_rcu(struct cds_lfs_stack_rcu *s) for (;;) { struct cds_lfs_node_rcu *head; + rcu_read_lock(); head = rcu_dereference(s->head); if (head) { struct cds_lfs_node_rcu *next = rcu_dereference(head->next); if (uatomic_cmpxchg(&s->head, head, next) == head) { + rcu_read_unlock(); return head; } else { /* Concurrent modification. Retry. */ + rcu_read_unlock(); continue; } } else { /* Empty stack */ + rcu_read_unlock(); return NULL; } }