From: Bryan Duxbury Date: Wed, 1 Jun 2011 17:43:39 +0000 (+0000) Subject: THRIFT-1187. rb: nonblocking_server shutdown race under Ruby 1.9 X-Git-Tag: 0.7.0~83 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=5218cc17427b81bcadbc9bc32e56ef6a4755e92e;p=common%2Fthrift.git 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 --- diff --git a/lib/rb/lib/thrift/server/nonblocking_server.rb b/lib/rb/lib/thrift/server/nonblocking_server.rb index fc57d141..911d6d53 100644 --- a/lib/rb/lib/thrift/server/nonblocking_server.rb +++ b/lib/rb/lib/thrift/server/nonblocking_server.rb @@ -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}"