lib/aerospike/cluster/connection.rb in aerospike-1.0.2 vs lib/aerospike/cluster/connection.rb in aerospike-1.0.3

- old
+ new

@@ -32,17 +32,21 @@ self end def connect(host, port, timeout) socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) - sockaddr = Socket.sockaddr_in(port, host) + @sockaddr = Socket.sockaddr_in(port, host) begin - socket.connect_nonblock(sockaddr) - rescue Errno::EINPROGRESS + socket.connect_nonblock(@sockaddr) + socket + rescue IO::WaitWritable, Errno::EINPROGRESS # Block until the socket is ready, then try again - IO.select([socket], [socket], [socket], timeout.to_f) - @sockaddr = sockaddr - return socket + IO.select(nil, [socket], nil, timeout.to_f) + begin + socket.connect_nonblock(@sockaddr) + rescue Errno::EISCONN + end + socket end end def write(buffer, length) total = 0