From 5671a55f8e974828fde5ce212b6c518bb4c3ebea Mon Sep 17 00:00:00 2001 From: Bryan Duxbury Date: Mon, 18 Apr 2011 17:29:06 +0000 Subject: [PATCH] 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 --- lib/rb/lib/thrift/server/nonblocking_server.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 -- 2.17.1