X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Furcu.c;h=a8c033a0bb7c960755428ec7a3caeff6b3f309e7;hb=1c7364b78b023245aa490007ce835a8ad530edf6;hp=2cac0b602d6694a945bef8692a9b38ed97c13152;hpb=99bfa9e9e88b273c5a3134eafb9c31938f3af7d6;p=urcu.git diff --git a/src/urcu.c b/src/urcu.c index 2cac0b6..a8c033a 100644 --- a/src/urcu.c +++ b/src/urcu.c @@ -23,6 +23,7 @@ * IBM's contributions to this file may be relicensed under LGPLv2 or later. */ +#define URCU_NO_COMPAT_IDENTIFIERS #define _BSD_SOURCE #define _LGPL_SOURCE #define _DEFAULT_SOURCE @@ -37,6 +38,7 @@ #include #include +#include #include #include #include @@ -264,17 +266,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); @@ -620,7 +630,9 @@ void alias_rcu_init(void); #endif #ifdef RCU_SIGNAL -static void sigrcu_handler(int signo, siginfo_t *siginfo, void *context) +static void sigrcu_handler(int signo __attribute__((unused)), + siginfo_t *siginfo __attribute__((unused)), + void *context __attribute__((unused))) { /* * Executing this cmm_smp_mb() is the only purpose of this signal handler.