THRIFT-1149. ruby: Nonblocking server fails when client connection is reset
authorBryan Duxbury <bryanduxbury@apache.org>
Mon, 18 Apr 2011 17:29:06 +0000 (17:29 +0000)
committerBryan Duxbury <bryanduxbury@apache.org>
Mon, 18 Apr 2011 17:29:06 +0000 (17:29 +0000)
In some situations, a disconnecting client could cause the nonblocking server to trip on an exception and take the whole server down. This patch rescues such errors and cleans up only the disconnected client.

Patch: Alex

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1094667 13f79535-47bb-0310-9956-ffa450edef68

lib/rb/lib/thrift/server/nonblocking_server.rb

index 9e1cfe6..fc57d14 100644 (file)
@@ -146,10 +146,14 @@ module Thrift
             break if read_signals == :shutdown
           end
           rd.each do |fd|
-            if fd.handle.eof?
+            begin
+              if fd.handle.eof?
+                remove_connection fd
+              else
+                read_connection fd
+              end
+            rescue Errno::ECONNRESET
               remove_connection fd
-            else
-              read_connection fd
             end
           end
         end
@@ -292,4 +296,4 @@ module Thrift
       end
     end
   end
-end
\ No newline at end of file
+end