lib/aerospike/cluster/connection.rb in aerospike-1.0.9 vs lib/aerospike/cluster/connection.rb in aerospike-1.0.10

- old
+ new

@@ -60,26 +60,31 @@ total += written rescue IO::WaitWritable, Errno::EAGAIN IO.select(nil, [@socket]) retry rescue => e - Aerospike::Exceptions::Connection.new("#{e}") + raise Aerospike::Exceptions::Connection.new("#{e}") end end end def read(buffer, length) total = 0 while total < length begin bytes = @socket.recv_nonblock(length - total) - buffer.write_binary(bytes, total) if bytes.bytesize > 0 + if bytes.bytesize > 0 + buffer.write_binary(bytes, total) + else + # connection is dead; return an error + raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::SERVER_NOT_AVAILABLE, "Connection to the server node is dead.") + end total += bytes.bytesize rescue IO::WaitReadable, Errno::EAGAIN IO.select([@socket], nil) retry rescue => e - Aerospike::Exceptions::Connection.new("#{e}") + raise Aerospike::Exceptions::Connection.new("#{e}") end end end def connected?