summaryrefslogtreecommitdiff
path: root/test/socket/test_socket.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/socket/test_socket.rb')
-rw-r--r--test/socket/test_socket.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb
index 01d4652..b3b6fee 100644
--- a/test/socket/test_socket.rb
+++ b/test/socket/test_socket.rb
@@ -410,4 +410,24 @@ class TestSocket < Test::Unit::TestCase
assert_equal(stamp.data[-8,8].unpack("Q")[0], t.subsec * 2**64)
end
+ def test_closed_read
+ require 'timeout'
+ require 'socket'
+ bug4390 = '[ruby-core:35203]'
+ server = TCPServer.new("localhost", 0)
+ serv_thread = Thread.new {server.accept}
+ begin sleep(0.1) end until serv_thread.stop?
+ sock = TCPSocket.new("localhost", server.addr[1])
+ client_thread = Thread.new do
+ sock.readline
+ end
+ begin sleep(0.1) end until client_thread.stop?
+ Timeout.timeout(1) do
+ sock.close
+ sock = nil
+ assert_raise(IOError, bug4390) {client_thread.join}
+ end
+ ensure
+ server.close
+ end
end if defined?(Socket)