Skip to content
Browse files

protection from unregister_from_event_loop being called several times

  • Loading branch information...
1 parent 479364c commit 434146f5038ebf962993a375fa1f8612ebd19bea @humanzz committed Oct 15, 2008
Showing with 9 additions and 5 deletions.
  1. +9 −5 lib/never_block/db/fibered_db_connection.rb
View
14 lib/never_block/db/fibered_db_connection.rb
@@ -11,20 +11,24 @@ def register_with_event_loop(loop)
if EM.reactor_running?
@em_connection = EM::attach(@io,EMConnectionHandler,self)
else
- raise "REACTOR NOT RUNNING YA ZALAMA"
+ raise "EventMachine reactor not running"
end
- elsif loop.class.name == "REV::Loop"
- loop.attach(RevConnectionHandler.new(@fd))
else
- raise "could not register with the event loop"
+ raise "Could not register with the event loop"
end
@loop = loop
end
# Unattaches the connection socket from the event loop
def unregister_from_event_loop
if @loop == :em
- @em_connection.detach
+ if @em_connection
+ @em_connection.detach
+ @em_connection = nil
+ true
+ else
+ false
+ end
else
raise NotImplementedError.new("unregister_from_event_loop not implemented for #{@loop}")
end

0 comments on commit 434146f

Please sign in to comment.
Something went wrong with that request. Please try again.