summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/net/ssh/service/forward.rb16
-rw-r--r--test/manual/test_forward.rb8
2 files changed, 18 insertions, 6 deletions
diff --git a/lib/net/ssh/service/forward.rb b/lib/net/ssh/service/forward.rb
index 024a9cb..fa3e4f0 100644
--- a/lib/net/ssh/service/forward.rb
+++ b/lib/net/ssh/service/forward.rb
@@ -213,8 +213,20 @@ module Net; module SSH; module Service
# Handles server close on the sending side by Miklós Fazekas
channel.on_eof do |ch|
debug { "eof #{type} on #{type} forwarded channel" }
- ch[:socket].send_pending
- ch[:socket].shutdown Socket::SHUT_WR
+ begin
+ ch[:socket].send_pending
+ ch[:socket].shutdown Socket::SHUT_WR
+ rescue IOError => e
+ if e.message =~ /closed/ then
+ debug { "epipe in on_eof => shallowing exception:#{e}" }
+ else
+ raise
+ end
+ rescue Errno::EPIPE => e
+ debug { "epipe in on_eof => shallowing exception:#{e}" }
+ rescue Errno::ENOTCONN => e
+ debug { "enotconn in on_eof => shallowing exception:#{e}" }
+ end
end
channel.on_close do |ch|
diff --git a/test/manual/test_forward.rb b/test/manual/test_forward.rb
index 194aed7..46ddb25 100644
--- a/test/manual/test_forward.rb
+++ b/test/manual/test_forward.rb
@@ -26,7 +26,7 @@ class TestForward < Test::Unit::TestCase
end
def ssh_start_params
- [localhost ,ENV['USER']]
+ [localhost ,ENV['USER']] #:verbose => :debug
end
def find_free_port
@@ -37,7 +37,7 @@ class TestForward < Test::Unit::TestCase
port
end
- def start_server_sending_lot_of_data(exceptions=nil)
+ def start_server_sending_lot_of_data(exceptions)
server = TCPServer.open(0)
Thread.start do
loop do
@@ -95,7 +95,7 @@ class TestForward < Test::Unit::TestCase
end
end
session.loop(0.1) { client_done.empty? }
- assert_equal "Broken pipe", "#{server_exc.pop}"
+ assert_equal "Broken pipe", "#{server_exc.pop}" unless server_exc.empty?
end
def test_loop_should_not_abort_when_local_side_of_forward_is_reset
@@ -118,7 +118,7 @@ class TestForward < Test::Unit::TestCase
end
end
session.loop(0.1) { client_done.empty? }
- assert_equal "Broken pipe", "#{server_exc.pop}"
+ assert_equal "Broken pipe", "#{server_exc.pop}" unless server_exc.empty?
end
def test_loop_should_not_abort_when_server_side_of_forward_is_closed