X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=src%2Furcu-defer-impl.h;h=f1fae9c0d15ce4364a44d511f2a4701febe0c4b5;hb=feb9779741e503a39fadc838d1b26984bfd51f7e;hp=969231f8b552aa733dc5aedd91c8fd86ece5981c;hpb=d60603e846c6d14893b57f627b1b66d751550486;p=urcu.git diff --git a/src/urcu-defer-impl.h b/src/urcu-defer-impl.h index 969231f..f1fae9c 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);