lib/fluent/plugin_helper/socket_option.rb in fluentd-1.0.0 vs lib/fluent/plugin_helper/socket_option.rb in fluentd-1.0.1
- old
+ new
@@ -22,11 +22,11 @@
module PluginHelper
module SocketOption
FORMAT_STRUCT_LINGER = 'I!I!' # { int l_onoff; int l_linger; }
FORMAT_STRUCT_TIMEVAL = 'L!L!' # { time_t tv_sec; suseconds_t tv_usec; }
- def socket_option_validate!(protocol, resolve_name: nil, linger_timeout: nil, recv_timeout: nil, send_timeout: nil)
+ def socket_option_validate!(protocol, resolve_name: nil, linger_timeout: nil, recv_timeout: nil, send_timeout: nil, receive_buffer_size: nil)
unless resolve_name.nil?
if protocol != :tcp && protocol != :udp && protocol != :tls
raise ArgumentError, "BUG: resolve_name in available for tcp/udp/tls"
end
end
@@ -35,11 +35,11 @@
raise ArgumentError, "BUG: linger_timeout is available for tcp/tls"
end
end
end
- def socket_option_set(sock, resolve_name: nil, nonblock: false, linger_timeout: nil, recv_timeout: nil, send_timeout: nil)
+ def socket_option_set(sock, resolve_name: nil, nonblock: false, linger_timeout: nil, recv_timeout: nil, send_timeout: nil, receive_buffer_size: nil)
unless resolve_name.nil?
sock.do_not_reverse_lookup = !resolve_name
end
if nonblock
sock.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK)
@@ -53,9 +53,12 @@
socket_option_set_one(sock, :SO_RCVTIMEO, optval)
end
if send_timeout
optval = [send_timeout.to_i, 0].pack(FORMAT_STRUCT_TIMEVAL)
socket_option_set_one(sock, :SO_SNDTIMEO, optval)
+ end
+ if receive_buffer_size
+ socket_option_set_one(sock, :SO_RCVBUF, receive_buffer_size.to_i)
end
sock
end
def socket_option_set_one(sock, option, value)