X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu-qsbr.c;h=af82fb7e6d3d6bbe3d6ef199c5c9d23ce9253163;hp=685efb5297dca06632697d810f5f078bc0aa835d;hb=19d0e7ef8f7998fb256017ba2da414d78b3cb91b;hpb=731ccb963c80afd067e20acee2f9bd7cb4875ffb diff --git a/urcu-qsbr.c b/urcu-qsbr.c index 685efb5..af82fb7 100644 --- a/urcu-qsbr.c +++ b/urcu-qsbr.c @@ -121,9 +121,22 @@ static void wait_gp(void) { /* Read reader_gp before read futex */ cmm_smp_rmb(); - if (uatomic_read(&rcu_gp.futex) == -1) - futex_noasync(&rcu_gp.futex, FUTEX_WAIT, -1, - NULL, NULL, 0); + if (uatomic_read(&rcu_gp.futex) != -1) + return; + while (futex_noasync(&rcu_gp.futex, FUTEX_WAIT, -1, + NULL, NULL, 0)) { + switch (errno) { + case EWOULDBLOCK: + /* Value already changed. */ + return; + case EINTR: + /* Retry if interrupted by signal. */ + break; /* Get out of switch. */ + default: + /* Unexpected error. */ + urcu_die(errno); + } + } } /* @@ -455,6 +468,8 @@ void rcu_register_thread(void) assert(URCU_TLS(rcu_reader).ctr == 0); mutex_lock(&rcu_registry_lock); + assert(!URCU_TLS(rcu_reader).registered); + URCU_TLS(rcu_reader).registered = 1; cds_list_add(&URCU_TLS(rcu_reader).node, ®istry); mutex_unlock(&rcu_registry_lock); _rcu_thread_online(); @@ -467,6 +482,8 @@ void rcu_unregister_thread(void) * with a waiting writer. */ _rcu_thread_offline(); + assert(URCU_TLS(rcu_reader).registered); + URCU_TLS(rcu_reader).registered = 0; mutex_lock(&rcu_registry_lock); cds_list_del(&URCU_TLS(rcu_reader).node); mutex_unlock(&rcu_registry_lock);