0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd::fs::aio: Improve stability of completion ring iteration.

This commit is contained in:
Jason Volk 2019-04-06 13:34:33 -07:00
parent d118a0e743
commit 161502452a

View file

@ -290,10 +290,11 @@ bool
ircd::fs::aio::for_each_completed(const std::function<bool (const request &)> &closure) ircd::fs::aio::for_each_completed(const std::function<bool (const request &)> &closure)
{ {
assert(system && system->head); assert(system && system->head);
const size_t max(system->head->nr); const auto &max{system->head->nr};
std::atomic_signal_fence(std::memory_order_acquire); volatile auto head(system->head->head);
for(auto i(system->head->head); i != system->head->tail; ++i) volatile const auto &tail(system->head->tail);
if(!closure(*reinterpret_cast<const request *>(system->ring[i % max].data))) for(; head != tail; ++head, head %= max)
if(!closure(*reinterpret_cast<const request *>(system->ring[head].data)))
return false; return false;
return true; return true;