summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/net/ssh/connection/session.rb9
-rw-r--r--lib/net/ssh/test/extensions.rb2
-rw-r--r--test/connection/test_session.rb3
3 files changed, 12 insertions, 2 deletions
diff --git a/lib/net/ssh/connection/session.rb b/lib/net/ssh/connection/session.rb
index 07b4daf..a69b4f6 100644
--- a/lib/net/ssh/connection/session.rb
+++ b/lib/net/ssh/connection/session.rb
@@ -176,6 +176,15 @@ module Net; module SSH; module Connection
def loop(wait=nil, &block)
running = block || Proc.new { busy? }
loop_forever { break unless process(wait, &running) }
+ begin
+ process(0)
+ rescue IOError => e
+ if e.message =~ /closed/
+ debug { "stream was closed after loop => shallowing exception so it will be re-raised in next loop" }
+ else
+ raise
+ end
+ end
end
# The core of the event loop. It processes a single iteration of the event
diff --git a/lib/net/ssh/test/extensions.rb b/lib/net/ssh/test/extensions.rb
index 5583ec6..b3b188a 100644
--- a/lib/net/ssh/test/extensions.rb
+++ b/lib/net/ssh/test/extensions.rb
@@ -155,7 +155,7 @@ module Net; module SSH; module Test
processed += 1 if reader.idle!
end
- raise "no readers were ready for reading, and none had any incoming packets" if processed == 0
+ raise "no readers were ready for reading, and none had any incoming packets" if processed == 0 && wait != 0
end
end
end
diff --git a/test/connection/test_session.rb b/test/connection/test_session.rb
index eba1ddf..571a53d 100644
--- a/test/connection/test_session.rb
+++ b/test/connection/test_session.rb
@@ -449,7 +449,7 @@ module Connection
end
def test_loop_should_call_process_until_process_returns_false
- IO.stubs(:select).with([socket],[],nil,nil).returns([[],[],[]])
+ session.expects(:process).with(0)
session.expects(:process).with(nil).times(4).returns(true,true,true,false).yields
n = 0
session.loop { n += 1 }
@@ -521,6 +521,7 @@ module Connection
private
def prep_exec(command, *data)
+ IO.expects(:select).with([socket],[],nil,0).returns([[],[],[]])
transport.mock_enqueue = true
transport.expect do |t, p|
assert_equal CHANNEL_OPEN, p.type