logstash-input-unix 3.1.1 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 211693d1622019fadfcdd5f41b94b7e15594abc983aa54000ea59353392b5d4e
4
- data.tar.gz: a8b25c6eb9e1627b502b9177f17510d0e631a72c87883058f3d1f2fa93cb145e
3
+ metadata.gz: d08cd56249929640b76c5c042f213648ba1fe60433d014cc7b0149a81deb3e25
4
+ data.tar.gz: b0a4c82212391528b48e921245e4828419bb7e94e702fbd1addab6f3b3a2f8a3
5
5
  SHA512:
6
- metadata.gz: 8c3c0d4cc5bcdee9fb3a32de4593764f9b458861401569ecd16b6055bb905b4d0bf06da68824d0a8358a77e7f4bce2546736a28c407a6a02535150e85364d375
7
- data.tar.gz: da09882dac50d95baef03af89fc1b577ddbd31576d28cbdd02dc42fa350284512050480b231dd59ac6da247d8ec84a71c728ab656a29eb1cf443c0b63a440353
6
+ metadata.gz: c417cbbcb7590aa3d56ffdfd491a66355c7009f6fc88a61fb02affa6c95f20f453f1589e18c398879f5c39f501b8325bc8f0baca4028cce47c502a08c68777f8
7
+ data.tar.gz: f8a6280450bb4eadfed1cbd5f4515c26d48b19edb2e22963a05999baaccbce5e2df1a7551fa547174c0cedade75d6dc0e38574901275d955267f58a79e711f55
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 3.1.3
2
+ - Fix: replace deprecated `File.exists?` with `File.exist?` for Ruby 3.4 (JRuby 10) compatibility [#31](https://github.com/logstash-plugins/logstash-input-unix/pull/31)
3
+
4
+ ## 3.1.2
5
+ - Fix: eliminate high CPU usage when data timeout is disabled and no data is available on the socket [#30](https://github.com/logstash-plugins/logstash-input-unix/pull/30)
6
+
1
7
  ## 3.1.1
2
8
  - Fix: unable to stop plugin (on LS 6.x) [#29](https://github.com/logstash-plugins/logstash-input-unix/pull/29)
3
9
  - Refactor: plugin internals got reviewed for `data_timeout => ...` to work reliably
@@ -84,16 +84,15 @@ class LogStash::Inputs::Unix < LogStash::Inputs::Base
84
84
  begin
85
85
  hostname = Socket.gethostname
86
86
  while !stop?
87
- data = socket.read_nonblock(16384, exception: false)
88
-
89
- if data == :wait_readable
90
- if @data_timeout == -1 || IO.select([socket], nil, nil, @data_timeout)
91
- next # retry socket read
92
- else
93
- # socket not ready after @data_timeout seconds
94
- @logger.info("Closing connection after read timeout", :path => @path)
95
- return
96
- end
87
+ data = io_interruptable_readpartial(socket, 16384, @data_timeout)
88
+
89
+ if data == :data_timeout
90
+ # socket not ready after @data_timeout seconds
91
+ @logger.info("Closing connection after read timeout", :path => @path)
92
+ return
93
+ elsif data == :stopping
94
+ @logger.trace("Shutdown in progress", :path => @path)
95
+ next # let next loop handle graceful stop
97
96
  end
98
97
 
99
98
  @codec.decode(data) do |event|
@@ -118,6 +117,35 @@ class LogStash::Inputs::Unix < LogStash::Inputs::Base
118
117
  end
119
118
  end
120
119
 
120
+ ##
121
+ # Emulates `IO#readpartial` with a timeout and our plugin's stop-condition,
122
+ # limiting blocking calls to windows of 10s or less to ensure it can be interrupted.
123
+ #
124
+ # @param readable_io [IO] the IO to read from
125
+ # @param maxlen [Integer] the max bytes to be read
126
+ # @param timeout [Number] the maximum number of seconds to , or -1 to disable timeouts
127
+ #
128
+ # @return [:data_timeout] if timeout was reached before bytes were available
129
+ # @return [:stopping] if plugin stop-condition was detected before bytes were available
130
+ # @return [String] a non-empty string if bytes became available before the timeout was reached
131
+ def io_interruptable_readpartial(readable_io, maxlen, timeout)
132
+
133
+ data_timeout_deadline = timeout < 0 ? nil : Time.now + timeout
134
+ maximum_blocking_seconds = timeout < 0 || timeout > 10 ? 10 : timeout
135
+
136
+ loop do
137
+ return :stopping if stop?
138
+ result = readable_io.read_nonblock(maxlen, exception: false)
139
+
140
+ return result if result.kind_of?(String)
141
+ raise EOFError if result.nil?
142
+
143
+ return :data_timeout if (data_timeout_deadline && data_timeout_deadline < Time.now)
144
+ IO.select([readable_io], nil, nil, maximum_blocking_seconds)
145
+ end
146
+ end
147
+ private :io_interruptable_readpartial
148
+
121
149
  private
122
150
  def server?
123
151
  @mode == "server"
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-unix'
4
- s.version = '3.1.1'
4
+ s.version = '3.1.3'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Reads events over a UNIX socket"
7
7
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
data/spec/spec_helper.rb CHANGED
@@ -13,7 +13,7 @@ class UnixSocketHelper
13
13
 
14
14
  def new_socket(path)
15
15
  @path = path
16
- File.unlink if File.exists?(path) && File.socket?(path)
16
+ File.unlink if File.exist?(path) && File.socket?(path)
17
17
  @socket = UNIXServer.new(path)
18
18
  self
19
19
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-unix
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2021-12-23 00:00:00.000000000 Z
10
+ date: 2026-02-11 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
13
+ name: logstash-core-plugin-api
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - ">="
@@ -19,9 +19,8 @@ dependencies:
19
19
  - - "<="
20
20
  - !ruby/object:Gem::Version
21
21
  version: '2.99'
22
- name: logstash-core-plugin-api
23
- prerelease: false
24
22
  type: :runtime
23
+ prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
26
25
  requirements:
27
26
  - - ">="
@@ -31,42 +30,42 @@ dependencies:
31
30
  - !ruby/object:Gem::Version
32
31
  version: '2.99'
33
32
  - !ruby/object:Gem::Dependency
33
+ name: logstash-mixin-ecs_compatibility_support
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
36
36
  - - "~>"
37
37
  - !ruby/object:Gem::Version
38
38
  version: '1.3'
39
- name: logstash-mixin-ecs_compatibility_support
40
- prerelease: false
41
39
  type: :runtime
40
+ prerelease: false
42
41
  version_requirements: !ruby/object:Gem::Requirement
43
42
  requirements:
44
43
  - - "~>"
45
44
  - !ruby/object:Gem::Version
46
45
  version: '1.3'
47
46
  - !ruby/object:Gem::Dependency
47
+ name: logstash-codec-line
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
- name: logstash-codec-line
54
- prerelease: false
55
53
  type: :runtime
54
+ prerelease: false
56
55
  version_requirements: !ruby/object:Gem::Requirement
57
56
  requirements:
58
57
  - - ">="
59
58
  - !ruby/object:Gem::Version
60
59
  version: '0'
61
60
  - !ruby/object:Gem::Dependency
61
+ name: logstash-devutils
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
- name: logstash-devutils
68
- prerelease: false
69
67
  type: :development
68
+ prerelease: false
70
69
  version_requirements: !ruby/object:Gem::Requirement
71
70
  requirements:
72
71
  - - ">="
@@ -97,7 +96,6 @@ licenses:
97
96
  metadata:
98
97
  logstash_plugin: 'true'
99
98
  logstash_group: input
100
- post_install_message:
101
99
  rdoc_options: []
102
100
  require_paths:
103
101
  - lib
@@ -112,8 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
110
  - !ruby/object:Gem::Version
113
111
  version: '0'
114
112
  requirements: []
115
- rubygems_version: 3.1.6
116
- signing_key:
113
+ rubygems_version: 3.6.3
117
114
  specification_version: 4
118
115
  summary: Reads events over a UNIX socket
119
116
  test_files: