summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklós Fazekas <mfazekas@szemafor.com>2018-02-06 10:50:09 +0100
committerGitHub <noreply@github.com>2018-02-06 10:50:09 +0100
commit9aa0a576a8100a7ba6acd4aa823041ad8f560d4a (patch)
tree857fa86edbfe363ac2463763b5ee0f704faafc1e
parent38d95432f454ea7b3d22804d619147d1d370ec2e (diff)
parente7f9cb5da7c2b860cfdd9df3578a789c6a1a4f68 (diff)
downloadnet-ssh-9aa0a576a8100a7ba6acd4aa823041ad8f560d4a.tar.gz
Merge pull request #544 from milgner/feature/remove-io-compat
Remove Net::SSH::Compat.io_select
-rw-r--r--lib/net/ssh/buffered_io.rb2
-rw-r--r--lib/net/ssh/connection/event_loop.rb4
-rw-r--r--lib/net/ssh/proxy/command.rb2
-rw-r--r--lib/net/ssh/ruby_compat.rb12
-rw-r--r--lib/net/ssh/transport/packet_stream.rb4
-rw-r--r--test/integration/test_proxy.rb11
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