THRIFT-1187. rb: nonblocking_server shutdown race under Ruby 1.9

This patch fixes a shutdown error that occurs under ruby 1.9.2

Patch: Ilya Maykov

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1130242 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bryan Duxbury 2011-06-01 17:43:39 +00:00
parent fb1412d916
commit 5218cc1742

View File

@ -44,7 +44,13 @@ module Thrift
begin
loop do
break if @server_transport.closed?
rd, = select([@server_transport], nil, nil, 0.1)
begin
rd, = select([@server_transport], nil, nil, 0.1)
rescue Errno::EBADF => e
# In Ruby 1.9, calling @server_transport.close in shutdown paths causes the select() to raise an
# Errno::EBADF. If this happens, ignore it and retry the loop.
next
end
next if rd.nil?
socket = @server_transport.accept
@logger.debug "Accepted socket: #{socket.inspect}"