From 6572c5f54ee53df08ae47684a11a0ae9885a64de Mon Sep 17 00:00:00 2001 From: Miklos Fazekas Date: Sat, 24 Jun 2017 07:24:51 +0200 Subject: Call a process after the loop so we actually send stuff enqueued by stuff in loop --- lib/net/ssh/connection/session.rb | 9 +++++++++ lib/net/ssh/test/extensions.rb | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'lib') 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 -- cgit v1.2.1