Project

General

Profile

Backport #670 » test_select_hangs_on_linux.rb

rogerdpack (Roger Pack), 10/21/2008 08:01 AM

 
# to run this one
# touch abc
# then
# ulimit -n 2000

require 'socket'

class TCPSocket
attr_accessor :wrote
end

no_files = 0

server_ports = []
clients = []

deplete_fds = []
begin
#loop { deplete_fds << File.new('abc', 'r')}
rescue Exception
end
print 'got', deplete_fds.length
begin
while true
another_server = TCPServer.new 'localhost', nil
port = another_server.addr[1]
clients << TCPSocket.new('localhost', port)
server_ports << another_server.accept
end
rescue Exception => e
print 'got', clients.length, e
end
print 'continuing'

for client in clients
what_to_write = rand(100000).to_s
client.write what_to_write
client.wrote = what_to_write
end

count = 0
for server_port in server_ports
print 'accepting, receiving', count
count += 1
received = server_port.recv 1024
server_port.write received
end
print 'herey'
for client in clients
received = client.recv(1024)
raise 'got back weird data' unless received == client.wrote
end
print 'success for ', clients.length

(3-3/5)