diff options
author | Marcus Ilgner <mail@marcusilgner.com> | 2017-09-07 16:55:42 +0200 |
---|---|---|
committer | Marcus Ilgner <mail@marcusilgner.com> | 2017-09-07 16:55:42 +0200 |
commit | e7f9cb5da7c2b860cfdd9df3578a789c6a1a4f68 (patch) | |
tree | cbeed6632c75fbf2619278351efa8994e19fe08d | |
parent | 4790748f9fad1aafda500d68747bc21a465f262c (diff) | |
download | net-ssh-e7f9cb5da7c2b860cfdd9df3578a789c6a1a4f68.tar.gz |
Remove Net::SSH::Compat.io_select
Despite the comment, it was not doing anything anymore except invoking
the default `IO.select`.
-rw-r--r-- | lib/net/ssh/buffered_io.rb | 2 | ||||
-rw-r--r-- | lib/net/ssh/connection/event_loop.rb | 4 | ||||
-rw-r--r-- | lib/net/ssh/proxy/command.rb | 2 | ||||
-rw-r--r-- | lib/net/ssh/ruby_compat.rb | 12 | ||||
-rw-r--r-- | lib/net/ssh/transport/packet_stream.rb | 4 | ||||
-rw-r--r-- | test/integration/test_proxy.rb | 11 |
6 files changed, 10 insertions, 25 deletions
diff --git a/lib/net/ssh/buffered_io.rb b/lib/net/ssh/buffered_io.rb index a8f8ddb..bbf8f4d 100644 --- a/lib/net/ssh/buffered_io.rb +++ b/lib/net/ssh/buffered_io.rb @@ -113,7 +113,7 @@ module Net; module SSH def wait_for_pending_sends send_pending while output.length > 0 - result = Net::SSH::Compat.io_select(nil, [self]) or next + result = IO.select(nil, [self]) or next next unless result[1].any? send_pending end diff --git a/lib/net/ssh/connection/event_loop.rb b/lib/net/ssh/connection/event_loop.rb index f9d95ea..ab1b49a 100644 --- a/lib/net/ssh/connection/event_loop.rb +++ b/lib/net/ssh/connection/event_loop.rb @@ -64,7 +64,7 @@ module Net; module SSH; module Connection sw.each { |wi| owners[wi] = session } end - readers, writers, = Net::SSH::Compat.io_select(r, w, nil, minwait) + readers, writers, = IO.select(r, w, nil, minwait) fired_sessions = {} @@ -105,7 +105,7 @@ module Net; module SSH; module Connection raise "Only one session expected" unless @sessions.count == 1 session = @sessions.first sr,sw,actwait = session.ev_do_calculate_rw_wait(wait) - readers, writers, = Net::SSH::Compat.io_select(sr, sw, nil, actwait) + readers, writers, = IO.select(sr, sw, nil, actwait) session.ev_do_handle_events(readers,writers) session.ev_do_postprocess(!((readers.nil? || readers.empty?) && (writers.nil? || writers.empty?))) diff --git a/lib/net/ssh/proxy/command.rb b/lib/net/ssh/proxy/command.rb index 5248059..4c9eb62 100644 --- a/lib/net/ssh/proxy/command.rb +++ b/lib/net/ssh/proxy/command.rb @@ -56,7 +56,7 @@ module Net; module SSH; module Proxy } begin io = IO.popen(command_line, "r+") - if result = Net::SSH::Compat.io_select([io], nil, [io], 60) + if result = IO.select([io], nil, [io], 60) if result.last.any? || io.eof? io.close raise "command failed" diff --git a/lib/net/ssh/ruby_compat.rb b/lib/net/ssh/ruby_compat.rb index d4abeb4..611f5ab 100644 --- a/lib/net/ssh/ruby_compat.rb +++ b/lib/net/ssh/ruby_compat.rb @@ -10,15 +10,3 @@ class String end end end - -module Net; module SSH - - # This class contains miscellaneous patches and workarounds - # for different ruby implementations. - class Compat - def self.io_select(*params) - IO.select(*params) - end - end - -end; end diff --git a/lib/net/ssh/transport/packet_stream.rb b/lib/net/ssh/transport/packet_stream.rb index 6555fc1..f8449d9 100644 --- a/lib/net/ssh/transport/packet_stream.rb +++ b/lib/net/ssh/transport/packet_stream.rb @@ -72,7 +72,7 @@ module Net; module SSH; module Transport # Returns true if the IO is available for reading, and false otherwise. def available_for_read? - result = Net::SSH::Compat.io_select([self], nil, nil, 0) + result = IO.select([self], nil, nil, 0) result && result.first.any? end @@ -105,7 +105,7 @@ module Net; module SSH; module Transport return packet if packet loop do - result = Net::SSH::Compat.io_select([self]) or next + result = IO.select([self]) or next break if result.first.any? end diff --git a/test/integration/test_proxy.rb b/test/integration/test_proxy.rb index f0e902b..ea65996 100644 --- a/test/integration/test_proxy.rb +++ b/test/integration/test_proxy.rb @@ -66,24 +66,21 @@ class TestProxy < NetSSHTest end def with_spurious_write_wakeup_emulate(rate=99,&block) - orig_io_select = Net::SSH::Compat.method(:io_select) + orig_io_select = IO.method(:select) count = 0 - Net::SSH::Compat.singleton_class.send(:define_method,:io_select) do |*params| + IO.singleton_class.send(:define_method, :select) do |*params| count += 1 if (count % rate != 0) if params && params[1] && !params[1].empty? return [[],params[1],[]] end - #if params && params[0] && !params[0].empty? - #return [params[0],[],[]] - #end end - IO.select(*params) + orig_io_select.call(*params) end begin yield ensure - Net::SSH::Compat.singleton_class.send(:define_method,:io_select,&orig_io_select) + IO.singleton_class.send(:define_method, :select, &orig_io_select) end end |