summary refs log tree commit homepage
path: root/lib/rainbows/event_machine.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rainbows/event_machine.rb')
-rw-r--r--lib/rainbows/event_machine.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/rainbows/event_machine.rb b/lib/rainbows/event_machine.rb
index b143b39..b326e26 100644
--- a/lib/rainbows/event_machine.rb
+++ b/lib/rainbows/event_machine.rb
@@ -88,7 +88,17 @@ module Rainbows::EventMachine
         raise RuntimeError, "EM @conns instance variable not accessible!"
       Rainbows::EventMachine::Server.const_set(:CUR, conns)
       Rainbows.at_quit do
-        EM.next_tick { conns.each_value { |c| client_class === c and c.quit } }
+        EM.next_tick do
+          LISTENERS.clear
+          conns.each_value do |c|
+            case c
+            when client_class
+              c.quit
+            when Rainbows::EventMachine::Server
+              c.detach
+            end
+          end
+        end
       end
       EM.add_periodic_timer(1) do
         EM.stop if ! Rainbows.tick && conns.empty? && EM.reactor_running?