def handle_servers
begin
check = @check
sockets = [check] + @binder.ios
pool = @thread_pool
while @status == :run
begin
ios = IO.select sockets
ios.first.each do |sock|
if sock == check
break if handle_check
else
begin
if io = sock.accept_nonblock
c = Client.new io, @binder.env(sock)
pool << c
end
rescue SystemCallError
end
end
end
rescue Errno::ECONNABORTED
client.close rescue nil
rescue Object => e
@events.unknown_error self, e, "Listen loop"
end
end
graceful_shutdown if @status == :stop || @status == :restart
@reactor.clear! if @status == :restart
@reactor.shutdown
rescue Exception => e
STDERR.puts "Exception handling servers: #{e.message} (#{e.class})"
STDERR.puts e.backtrace
ensure
@check.close
@notify.close
if @status != :restart and @own_binder
@binder.close
end
end
end