From 0bd7d3830d01525f2a1620eb3a3da19fdd3f8cb8 Mon Sep 17 00:00:00 2001 From: Tyler Brock Date: Thu, 5 Apr 2012 12:47:17 -0400 Subject: [PATCH] RUBY-429 wrap IO errors from select and read --- lib/mongo/util/tcp_socket.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/mongo/util/tcp_socket.rb b/lib/mongo/util/tcp_socket.rb index 1b9c465..a5cd7af 100644 --- a/lib/mongo/util/tcp_socket.rb +++ b/lib/mongo/util/tcp_socket.rb @@ -60,14 +60,19 @@ module Mongo def read(maxlen, buffer) # Block on data to read for @op_timeout seconds - if IO.select([@socket], nil, [@socket], @op_timeout) + begin + ready = IO.select([@socket], nil, [@socket], @op_timeout) + rescue IOError + raise OperationFailure + end + if ready begin @socket.readpartial(maxlen, buffer) rescue EOFError return ConnectionError rescue Errno::ENOTCONN, Errno::EBADF, Errno::ECONNRESET, Errno::EPIPE raise ConnectionFailure - rescue Errno::EINTR, Errno::EIO + rescue Errno::EINTR, Errno::EIO, IOError raise OperationFailure end else