diff --git a/Source/AuProcAddresses.Linux.cpp b/Source/AuProcAddresses.Linux.cpp index 86b98ef7..d79bfc62 100644 --- a/Source/AuProcAddresses.Linux.cpp +++ b/Source/AuProcAddresses.Linux.cpp @@ -19,8 +19,6 @@ namespace Aurora { - #define read_barrier() __asm__ __volatile__("lfence" ::: "memory") - static const auto kAioRingMagic = 0xa10a10a1u; void InitLinuxAddresses() @@ -227,15 +225,21 @@ namespace Aurora while (i < max_nr) { - auto head = pRing->head; + auto head = AuAtomicLoad(&pRing->head); if (head == pRing->tail) { break; } events[i++] = pRing->events[head]; - read_barrier(); - pRing->head = (head + 1) % pRing->nr; + + auto nextHead = (head + 1) % pRing->nr; + if (AuAtomicCompareExchange(&pRing->head, + nextHead, + head) != head) + { + i--; + } } if (!i &&