Module: Net::SSH::ForwardedBufferedIo

Defined in:
lib/net/ssh/buffered_io.rb

Overview

Fixes for two issues by Miklós Fazekas:

* if client closes a forwarded connection, but the server is
  reading, net-ssh terminates with IOError socket closed.
* if client force closes (RST) a forwarded connection, but
  server is reading, net-ssh terminates with [an exception]

See:

http://net-ssh.lighthouseapp.com/projects/36253/tickets/7
http://github.com/net-ssh/net-ssh/tree/portfwfix

Instance Method Summary collapse

Instance Method Details

#fill(n = 8192) ⇒ Object



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/net/ssh/buffered_io.rb', line 169

def fill(n = 8192)
  begin
    super(n)
  rescue Errno::ECONNRESET => e
    debug { "connection was reset => shallowing exception:#{e}" }
    return 0
  rescue IOError => e
    if e.message =~ /closed/ then
      debug { "connection was reset => shallowing exception:#{e}" }
      return 0
    else
      raise
    end
  end
end

#send_pendingObject



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/net/ssh/buffered_io.rb', line 185

def send_pending
  begin
    super
  rescue Errno::ECONNRESET => e
    debug { "connection was reset => shallowing exception:#{e}" }
    return 0
  rescue IOError => e
    if e.message =~ /closed/ then
      debug { "connection was reset => shallowing exception:#{e}" }
      return 0
    else
      raise
    end
  end
end