Class: Thrift::Socket

Inherits:
Object show all
Defined in:
lib/right_support/db/cassandra_model.rb

Instance Method Summary collapse

Instance Method Details

#openObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/right_support/db/cassandra_model.rb', line 76

def open
  begin
    addrinfo = ::Socket::getaddrinfo(@host, @port).first
    @handle = ::Socket.new(addrinfo[4], ::Socket::SOCK_STREAM, 0)
    sockaddr = ::Socket.sockaddr_in(addrinfo[1], addrinfo[3])
    begin
      @handle.connect_nonblock(sockaddr)
    rescue Errno::EINPROGRESS
      resp = IO.select(nil, [ @handle ], nil, @timeout) # 3 lines removed here, 1 line added
      begin
        @handle.connect_nonblock(sockaddr)
      rescue Errno::EISCONN
      end
    end
    @handle
  rescue StandardError => e
    raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
  end
end