From 162e889f16ceb47978fe9bc81ac0b46672f05ff0 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Wed, 30 Nov 2016 22:22:36 +1030 Subject: Prevent race condition when launching EventMachine reactor reactor_running? will be true just after the thread enters EventMachine.run; reactor_thread only gets set after the internal initialize_event_machine method has been called, the C extension is set up, and it is entering its run loop. --- actioncable/lib/action_cable/subscription_adapter/evented_redis.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actioncable/lib/action_cable/subscription_adapter') diff --git a/actioncable/lib/action_cable/subscription_adapter/evented_redis.rb b/actioncable/lib/action_cable/subscription_adapter/evented_redis.rb index bcd46d2a0e..c3018c5281 100644 --- a/actioncable/lib/action_cable/subscription_adapter/evented_redis.rb +++ b/actioncable/lib/action_cable/subscription_adapter/evented_redis.rb @@ -68,10 +68,10 @@ module ActionCable end def ensure_reactor_running - return if EventMachine.reactor_running? + return if EventMachine.reactor_running? && EventMachine.reactor_thread @@mutex.synchronize do Thread.new { EventMachine.run } unless EventMachine.reactor_running? - Thread.pass until EventMachine.reactor_running? + Thread.pass until EventMachine.reactor_running? && EventMachine.reactor_thread end end end -- cgit v1.2.3