X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=src%2Furcu.c;fp=src%2Furcu.c;h=59f2e8f18fdddc5a781e25d2478ca86e18a9fee5;hp=67c6525ddc9479cd0c63de0805998c99fa32b07c;hb=a18d0428065b301086d4e8a85bc057dc39946891;hpb=71693131550753be0fcd2b2d4175b53c697be5a3 diff --git a/src/urcu.c b/src/urcu.c index 67c6525..59f2e8f 100644 --- a/src/urcu.c +++ b/src/urcu.c @@ -259,17 +259,25 @@ static void wait_gp(void) smp_mb_master(); /* Temporarily unlock the registry lock. */ mutex_unlock(&rcu_registry_lock); - if (uatomic_read(&rcu_gp.futex) != -1) - goto end; - while (futex_async(&rcu_gp.futex, FUTEX_WAIT, -1, - NULL, NULL, 0)) { + while (uatomic_read(&rcu_gp.futex) == -1) { + if (!futex_async(&rcu_gp.futex, FUTEX_WAIT, -1, NULL, NULL, 0)) { + /* + * Prior queued wakeups queued by unrelated code + * using the same address can cause futex wait to + * return 0 even through the futex value is still + * -1 (spurious wakeups). Check the value again + * in user-space to validate whether it really + * differs from -1. + */ + continue; + } switch (errno) { - case EWOULDBLOCK: + case EAGAIN: /* Value already changed. */ goto end; case EINTR: /* Retry if interrupted by signal. */ - break; /* Get out of switch. */ + break; /* Get out of switch. Check again. */ default: /* Unexpected error. */ urcu_die(errno);