You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by br...@apache.org on 2011/06/01 19:43:39 UTC

svn commit: r1130242 - /thrift/trunk/lib/rb/lib/thrift/server/nonblocking_server.rb

Author: bryanduxbury
Date: Wed Jun  1 17:43:39 2011
New Revision: 1130242

URL: http://svn.apache.org/viewvc?rev=1130242&view=rev
Log:
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

Modified:
    thrift/trunk/lib/rb/lib/thrift/server/nonblocking_server.rb

Modified: thrift/trunk/lib/rb/lib/thrift/server/nonblocking_server.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/lib/thrift/server/nonblocking_server.rb?rev=1130242&r1=1130241&r2=1130242&view=diff
==============================================================================
--- thrift/trunk/lib/rb/lib/thrift/server/nonblocking_server.rb (original)
+++ thrift/trunk/lib/rb/lib/thrift/server/nonblocking_server.rb Wed Jun  1 17:43:39 2011
@@ -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}"