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 9e1cfe6..fc57d14 100644
--- a/lib/rb/lib/thrift/server/nonblocking_server.rb
+++ b/lib/rb/lib/thrift/server/nonblocking_server.rb
@@ -146,10 +146,14 @@
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 @@
end
end
end
-end
\ No newline at end of file
+end