Removed
Link Here
|
1 |
--- lib/riemann/client/tcp_socket.rb.orig 2019-11-25 11:01:31 UTC |
2 |
+++ lib/riemann/client/tcp_socket.rb |
3 |
@@ -107,13 +107,14 @@ module Riemann |
4 |
# Using the options from the initializer, a new ::Socket is created that |
5 |
# is: |
6 |
# |
7 |
- # TCP, IPv4 only, autoclosing on exit, nagle's algorithm is disabled and has |
8 |
+ # TCP, autoclosing on exit, nagle's algorithm is disabled and has |
9 |
# TCP Keepalive options set if keepalive is supported. |
10 |
# |
11 |
- # Returns a new ::Socket instance |
12 |
- def blank_socket |
13 |
- sock = ::Socket.new(::Socket::AF_INET, ::Socket::SOCK_STREAM, 0) |
14 |
+ # Returns a new ::Socket instance for |
15 |
|
16 |
+ def socket_factory(type) |
17 |
+ sock = ::Socket.new(type, ::Socket::SOCK_STREAM, 0) |
18 |
+ |
19 |
# close file descriptors if we exec |
20 |
if Fcntl.constants.include?(:F_SETFD) && Fcntl.constants.include?(:FD_CLOEXEC) |
21 |
sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) |
22 |
@@ -167,13 +168,14 @@ module Riemann |
23 |
# Calculate our timeout deadline |
24 |
deadline = Time.now.to_f + connect_timeout |
25 |
|
26 |
- # Lookup destination address, we only want IPv4 , TCP |
27 |
- addrs = ::Socket.getaddrinfo(host, port, ::Socket::AF_INET, ::Socket::SOCK_STREAM ) |
28 |
+ # Lookup destination address, we only want TCP. |
29 |
+ addrs = ::Socket.getaddrinfo(host, port, nil, ::Socket::SOCK_STREAM ) |
30 |
errors = [] |
31 |
conn_error = lambda { raise errors.first } |
32 |
sock = nil |
33 |
|
34 |
- addrs.find( conn_error ) do |addr| |
35 |
+ # Sort it so we get AF_INET, IPv4 |
36 |
+ addrs.sort.find( conn_error ) do |addr| |
37 |
sock = connect_or_error( addr, deadline, errors ) |
38 |
end |
39 |
return sock |
40 |
@@ -210,7 +212,7 @@ module Riemann |
41 |
# connection was possible. |
42 |
def connect_nonblock( addr, timeout ) |
43 |
sockaddr = ::Socket.pack_sockaddr_in(addr[1], addr[3]) |
44 |
- sock = blank_socket() |
45 |
+ sock = self.socket_factory( addr[4] ) |
46 |
sock.connect_nonblock( sockaddr ) |
47 |
return sock |
48 |
rescue Errno::EINPROGRESS |