#include <stdbool.h>
#include <poll.h>
+#include <urcu/config.h>
#include <urcu/arch.h>
#include <urcu/wfcqueue.h>
#include <urcu/map/urcu.h>
static int init_done;
void __attribute__((constructor)) rcu_init(void);
-void __attribute__((destructor)) rcu_exit(void);
#endif
+void __attribute__((destructor)) rcu_exit(void);
+static void urcu_call_rcu_exit(void);
+
/*
* rcu_gp_lock ensures mutual exclusion between threads calling
* synchronize_rcu().
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);
#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.
URCU_ATTR_ALIAS(urcu_stringify(rcu_init))
void alias_rcu_init(void);
+/*
+ * Don't unregister the SIGRCU signal handler anymore, because
+ * call_rcu threads could still be using it shortly before the
+ * application exits.
+ * Assertion disabled because call_rcu threads are now rcu
+ * readers, and left running at exit.
+ * assert(cds_list_empty(®istry));
+ */
+
+#endif /* #ifdef RCU_SIGNAL */
+
void rcu_exit(void)
{
- /*
- * Don't unregister the SIGRCU signal handler anymore, because
- * call_rcu threads could still be using it shortly before the
- * application exits.
- * Assertion disabled because call_rcu threads are now rcu
- * readers, and left running at exit.
- * assert(cds_list_empty(®istry));
- */
+ urcu_call_rcu_exit();
}
URCU_ATTR_ALIAS(urcu_stringify(rcu_exit))
void alias_rcu_exit(void);
-#endif /* #ifdef RCU_SIGNAL */
-
DEFINE_RCU_FLAVOR(rcu_flavor);
DEFINE_RCU_FLAVOR_ALIAS(rcu_flavor, alias_rcu_flavor);