Patch-Source: https://github.com/eventmachine/eventmachine/commit/e29ccdefbf4b753dfec513c2df17b3bf1b827425.patch -- From e29ccdefbf4b753dfec513c2df17b3bf1b827425 Mon Sep 17 00:00:00 2001 From: wordjelly Date: Sun, 6 Sep 2020 10:02:31 +0530 Subject: [PATCH] fix: em/pure_ruby intra-iteration element delete bug (#929) --- lib/em/pure_ruby.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/em/pure_ruby.rb b/lib/em/pure_ruby.rb index f5a93675d..70b28fd6b 100644 --- a/lib/em/pure_ruby.rb +++ b/lib/em/pure_ruby.rb @@ -569,14 +569,18 @@ def run end def run_timers + timers_to_delete = [] @timers.each {|t| if t.first <= @current_loop_time - @timers.delete t + #@timers.delete t + timers_to_delete << t EventMachine::event_callback "", TimerFired, t.last else break end } + timers_to_delete.map{|c| @timers.delete c} + timers_to_delete = nil #while @timers.length > 0 and @timers.first.first <= now # t = @timers.shift # EventMachine::event_callback "", TimerFired, t.last