From 3371925d1804e6b7a4e94ef928ea897ded5e09fb Mon Sep 17 00:00:00 2001 From: Bryan Duxbury Date: Tue, 13 Dec 2011 18:33:15 +0000 Subject: [PATCH] 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 --- lib/rb/lib/thrift/transport/socket.rb | 4 ++-- lib/rb/spec/socket_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rb/lib/thrift/transport/socket.rb b/lib/rb/lib/thrift/transport/socket.rb index 9bb20361..dfb33fdb 100644 --- a/lib/rb/lib/thrift/transport/socket.rb +++ b/lib/rb/lib/thrift/transport/socket.rb @@ -34,7 +34,7 @@ module Thrift 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 @@ module Thrift @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 18250512..d5ae6b03 100644 --- a/lib/rb/spec/socket_spec.rb +++ b/lib/rb/spec/socket_spec.rb @@ -41,14 +41,14 @@ class ThriftSocketSpec < Spec::ExampleGroup 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 -- 2.17.1