Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add thread safety around the BufferedTokenizer usage #13

Merged
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+9 −5
Diff settings

Always

Just for now

@@ -1,3 +1,6 @@
## 3.0.6

This comment has been minimized.

Copy link
@jakelandis

jakelandis Dec 12, 2017

Contributor

👍

- Fixed thread safety issue. See https://github.com/logstash-plugins/logstash-codec-line/pull/13

## 3.0.5
- Update gemspec summary

@@ -1,6 +1,7 @@
# encoding: utf-8
require "logstash/codecs/base"
require "logstash/util/charset"
require "thread"

# Line-oriented text data.
#
@@ -31,18 +32,18 @@ def register
@buffer = FileWatch::BufferedTokenizer.new(@delimiter)
@converter = LogStash::Util::Charset.new(@charset)
@converter.logger = @logger
@buffer_mutex = Mutex.new
end

public
def decode(data)
@buffer.extract(data).each do |line|
yield LogStash::Event.new("message" => @converter.convert(line))
end
lines = @buffer_mutex.synchronize { @buffer.extract(data) }
lines.each { |line| yield LogStash::Event.new("message" => @converter.convert(line)) }
end # def decode

public
def flush(&block)
remainder = @buffer.flush
remainder = @buffer_mutex.synchronize { @buffer.flush }
if !remainder.empty?
block.call(LogStash::Event.new("message" => @converter.convert(remainder)))
end
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|

s.name = 'logstash-codec-line'
s.version = '3.0.5'
s.version = '3.0.6'
s.licenses = ['Apache License (2.0)']
s.summary = "Reads line-oriented text data"
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"
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.