From: Bryan Duxbury Date: Mon, 18 Apr 2011 17:29:06 +0000 (+0000) Subject: THRIFT-1149. ruby: Nonblocking server fails when client connection is reset X-Git-Tag: 0.7.0~107 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=5671a55f8e974828fde5ce212b6c518bb4c3ebea;p=common%2Fthrift.git THRIFT-1149. ruby: Nonblocking server fails when client connection is reset 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 --- diff --git a/lib/rb/lib/thrift/server/nonblocking_server.rb b/lib/rb/lib/thrift/server/nonblocking_server.rb index 9e1cfe6b..fc57d141 100644 --- a/lib/rb/lib/thrift/server/nonblocking_server.rb +++ b/lib/rb/lib/thrift/server/nonblocking_server.rb @@ -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