Skip to content

Commit 0bd7d38

Browse files
committed
RUBY-429 wrap IO errors from select and read
1 parent dfca0dd commit 0bd7d38

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/mongo/util/tcp_socket.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,19 @@ def send(data)
6060

6161
def read(maxlen, buffer)
6262
# Block on data to read for @op_timeout seconds
63-
if IO.select([@socket], nil, [@socket], @op_timeout)
63+
begin
64+
ready = IO.select([@socket], nil, [@socket], @op_timeout)
65+
rescue IOError
66+
raise OperationFailure
67+
end
68+
if ready
6469
begin
6570
@socket.readpartial(maxlen, buffer)
6671
rescue EOFError
6772
return ConnectionError
6873
rescue Errno::ENOTCONN, Errno::EBADF, Errno::ECONNRESET, Errno::EPIPE
6974
raise ConnectionFailure
70-
rescue Errno::EINTR, Errno::EIO
75+
rescue Errno::EINTR, Errno::EIO, IOError
7176
raise OperationFailure
7277
end
7378
else

0 commit comments

Comments
 (0)