From 756e8545f9967b7570e632d115d227f9f8cc321c Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Fri, 27 Sep 2024 09:44:07 +0900 Subject: [PATCH] in_syslog: add receive_buffer_size parameter in transport Signed-off-by: Shizuo Fujita --- lib/fluent/plugin/in_syslog.rb | 4 +++- test/plugin/test_in_syslog.rb | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/fluent/plugin/in_syslog.rb b/lib/fluent/plugin/in_syslog.rb index 28ad1c5dd9..0cdba47c7b 100644 --- a/lib/fluent/plugin/in_syslog.rb +++ b/lib/fluent/plugin/in_syslog.rb @@ -114,6 +114,8 @@ class SyslogInput < Input # overwrite server plugin to change default to :udp config_section :transport, required: false, multi: false, init: true, param_name: :transport_config do config_argument :protocol, :enum, list: [:tcp, :udp, :tls], default: :udp + desc "The max size of socket receive buffer. SO_RCVBUF" + config_param :receive_buffer_size, :size, default: nil end def configure(conf) @@ -170,7 +172,7 @@ def start end def start_udp_server - server_create_udp(:in_syslog_udp_server, @port, bind: @bind, max_bytes: @message_length_limit, resolve_name: @resolve_hostname) do |data, sock| + server_create_udp(:in_syslog_udp_server, @port, bind: @bind, max_bytes: @message_length_limit, resolve_name: @resolve_hostname, receive_buffer_size: @transport_config.receive_buffer_size) do |data, sock| message_handler(data.chomp, sock) end end diff --git a/test/plugin/test_in_syslog.rb b/test/plugin/test_in_syslog.rb index f715e1fef9..203194e6d4 100755 --- a/test/plugin/test_in_syslog.rb +++ b/test/plugin/test_in_syslog.rb @@ -92,6 +92,14 @@ def test_respect_protocol_type_than_transport compare_test_result(d.events, tests) end + data('Default receive_buffer_size' => ["\n ", nil], + 'Use receive_buffer_size' => ["\n receive_buffer_size 1234567\n ", 1234567],) + def test_transport_receive_buffer_size(param) + conf, expected = *param + d = create_driver([ipv4_config, conf].join("\n")) + + assert_equal(expected, d.instance.transport_config.receive_buffer_size) + end data( ipv4: ['127.0.0.1', :ipv4, ::Socket::AF_INET],