THRIFT-1449. rb: Ruby client does not work on solaris (?)
This patch adds a new argument to the socket calls that seems to fix the problems while not causing any detriment to non-Solaris systems.
Patch: Erik Hetzner
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1213837 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/lib/thrift/transport/socket.rb b/lib/rb/lib/thrift/transport/socket.rb
index 9bb2036..dfb33fd 100644
--- a/lib/rb/lib/thrift/transport/socket.rb
+++ b/lib/rb/lib/thrift/transport/socket.rb
@@ -34,7 +34,7 @@
def open
begin
- addrinfo = ::Socket::getaddrinfo(@host, @port).first
+ addrinfo = ::Socket::getaddrinfo(@host, @port, nil, ::Socket::SOCK_STREAM).first
@handle = ::Socket.new(addrinfo[4], ::Socket::SOCK_STREAM, 0)
sockaddr = ::Socket.sockaddr_in(addrinfo[1], addrinfo[3])
begin
@@ -134,4 +134,4 @@
@handle
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/rb/spec/socket_spec.rb b/lib/rb/spec/socket_spec.rb
index 1825051..d5ae6b0 100644
--- a/lib/rb/spec/socket_spec.rb
+++ b/lib/rb/spec/socket_spec.rb
@@ -41,14 +41,14 @@
it "should open a ::Socket with default args" do
::Socket.should_receive(:new).and_return(mock("Handle", :connect_nonblock => true))
- ::Socket.should_receive(:getaddrinfo).with("localhost", 9090).and_return([[]])
+ ::Socket.should_receive(:getaddrinfo).with("localhost", 9090, nil, ::Socket::SOCK_STREAM).and_return([[]])
::Socket.should_receive(:sockaddr_in)
@socket.open
end
it "should accept host/port options" do
::Socket.should_receive(:new).and_return(mock("Handle", :connect_nonblock => true))
- ::Socket.should_receive(:getaddrinfo).with("my.domain", 1234).and_return([[]])
+ ::Socket.should_receive(:getaddrinfo).with("my.domain", 1234, nil, ::Socket::SOCK_STREAM).and_return([[]])
::Socket.should_receive(:sockaddr_in)
Socket.new('my.domain', 1234).open
end