lib/bunny/session.rb in bunny-0.10.0 vs lib/bunny/session.rb in bunny-0.10.1
- old
+ new
@@ -267,11 +267,13 @@
Bunny::Timer.timeout(@transport.disconnect_timeout, ClientTimeout) do
self.close_connection(true)
end
+ # puts "before maybe_shutdown_reader_loop"
maybe_shutdown_reader_loop
+ # puts "after maybe_shutdown_reader_loop"
close_transport
@status = :closed
end
end
@@ -624,13 +626,22 @@
# @private
def maybe_shutdown_reader_loop
if @reader_loop
@reader_loop.stop
- # We don't need to kill the loop but
# this is the easiest way to wait until the loop
# is guaranteed to have terminated
- @reader_loop.kill
+ @reader_loop.raise(ShutdownSignal)
+ # joining the thread here may take forever
+ # on JRuby because sun.nio.ch.KQueueArrayWrapper#kevent0 is
+ # a native method that cannot be (easily) interrupted.
+ # So we use this ugly hack or else our test suite takes forever
+ # to run on JRuby (a new connection is opened/closed per example). MK.
+ if RUBY_ENGINE == "jruby"
+ sleep 0.075
+ else
+ @reader_loop.join
+ end
end
@reader_loop = nil
end