summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-03-11 12:49:10 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-03-11 12:49:10 -0400
commita249bfa18e492a4317d739f7b9d839b796f005ba (patch)
tree153334f3f624d9a608a091e438dbf0dd116b4ea9
parentc12a3c9f5bc085a67ef0fc2c764a9692bcab2b66 (diff)
Make WaitQueue:_wait_waiters() skip dead coroutines.
That is, skip coroutines that have gone dead since they decided to wait on Dequeue().
-rw-r--r--indra/newview/scripts/lua/WaitQueue.lua21
1 files changed, 14 insertions, 7 deletions
diff --git a/indra/newview/scripts/lua/WaitQueue.lua b/indra/newview/scripts/lua/WaitQueue.lua
index e6adde0573..00766ccae7 100644
--- a/indra/newview/scripts/lua/WaitQueue.lua
+++ b/indra/newview/scripts/lua/WaitQueue.lua
@@ -37,14 +37,21 @@ function WaitQueue:_wake_waiters()
-- or Dequeue() calls, recheck every time around to see if we must resume
-- another waiting coroutine.
while not self:IsEmpty() and #self._waiters > 0 do
- -- pop the oldest waiting coroutine instead of the most recent, for
- -- more-or-less round robin fairness
+ -- Pop the oldest waiting coroutine instead of the most recent, for
+ -- more-or-less round robin fairness. But skip any coroutines that
+ -- have gone dead in the meantime.
local waiter = table.remove(self._waiters, 1)
- -- don't pass the head item: let the resumed coroutine retrieve it
- local ok, message = coroutine.resume(waiter)
- -- if resuming that waiter encountered an error, don't swallow it
- if not ok then
- error(message)
+ while waiter and coroutine.status(waiter) ~= "suspended" do
+ waiter = table.remove(self._waiters, 1)
+ end
+ -- do we still have at least one waiting coroutine?
+ if waiter then
+ -- don't pass the head item: let the resumed coroutine retrieve it
+ local ok, message = coroutine.resume(waiter)
+ -- if resuming that waiter encountered an error, don't swallow it
+ if not ok then
+ error(message)
+ end
end
end
end