lib/bunny/session.rb in bunny-0.9.4 vs lib/bunny/session.rb in bunny-0.9.5

- old
+ new

@@ -368,17 +368,19 @@ end end # @private def close_connection(sync = true) - @transport.send_frame(AMQ::Protocol::Connection::Close.encode(200, "Goodbye", 0, 0)) + if @transport.open? + @transport.send_frame(AMQ::Protocol::Connection::Close.encode(200, "Goodbye", 0, 0)) - maybe_shutdown_heartbeat_sender - @status = :not_connected + maybe_shutdown_heartbeat_sender + @status = :not_connected - if sync - @last_connection_close_ok = wait_on_continuations + if sync + @last_connection_close_ok = wait_on_continuations + end end end # @private def handle_frame(ch_number, method) @@ -390,10 +392,10 @@ @continuations.push(method) when AMQ::Protocol::Connection::Close then @last_connection_error = instantiate_connection_level_exception(method) @continuations.push(method) - raise @last_connection_error + @origin_thread.raise(@last_connection_error) when AMQ::Protocol::Connection::CloseOk then @last_connection_close_ok = method begin @continuations.clear