X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=src%2Furcu-defer-impl.h;fp=src%2Furcu-defer-impl.h;h=b5d79262c03bb88a28cd376d78c4189ca3c578cd;hp=d25e9b93f4dc17e8f1e6ee986ad04cdca366527f;hb=879a3e166178d16b2ffedc73899904d52285cfe8;hpb=98d705dd32be11b3f134b5aed87f9c201c028c10 diff --git a/src/urcu-defer-impl.h b/src/urcu-defer-impl.h index d25e9b9..b5d7926 100644 --- a/src/urcu-defer-impl.h +++ b/src/urcu-defer-impl.h @@ -194,17 +194,25 @@ static void wait_defer(void) uatomic_set(&defer_thread_futex, 0); } else { cmm_smp_rmb(); /* Read queue before read futex */ - if (uatomic_read(&defer_thread_futex) != -1) - return; - while (futex_noasync(&defer_thread_futex, FUTEX_WAIT, -1, - NULL, NULL, 0)) { + while (uatomic_read(&defer_thread_futex) == -1) { + if (!futex_noasync(&defer_thread_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. */ return; 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);