317: def disconnect
318: return unless @rye_ssh && !@rye_ssh.closed?
319: begin
320: debug "removing active forwards"
321: remove_hops!
322: debug "killing port_loop @rye_port_thread"
323: @rye_port_thread.kill
324: if @rye_ssh.busy?;
325: info "Is something still running? (ctrl-C to exit)"
326: Timeout::timeout(10) do
327: @rye_ssh.loop(0.3) { @rye_ssh.busy?; }
328: end
329: end
330: debug "Closing connection to #{@rye_ssh.host}"
331: @rye_ssh.close
332: if @rye_via
333: debug "disconnecting Hop #{@rye_via.host}"
334: @rye_via.disconnect
335: end
336: rescue SystemCallError, Timeout::Error => ex
337: error "Rye::Hop: Disconnect timeout (#{ex.message})"
338: debug ex.backtrace
339: rescue Interrupt
340: debug "Exiting..."
341: end
342: end