Class: Net::SSH::Connection::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/em-ssh/ext/net/ssh/connection/channel.rb

Overview

Moneky patching is the root of all evil.

Net:SSH::Connection::Channel doesn’t expect its #connection to every be nil. EM::Ssh unsets the Channels @connection to facilitate garbage collection when the session is closed. Anything that maintains a reference to a Channel could still call Channel#wait, Channel#active?, so we need a guard in those methods.

TODO be a good citizen. Verify that the possible memory leak in EM::Ssh::Session is also possible in Net::SSHi::Connection and submit a pull request with fixes.

Instance Method Summary collapse

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/em-ssh/ext/net/ssh/connection/channel.rb', line 14

def active?
  return unless connection
  connection.channels.key?(local_id)
end

#waitObject



19
20
21
22
# File 'lib/em-ssh/ext/net/ssh/connection/channel.rb', line 19

def wait
  return unless connection
  connection.loop { active? }
end