From e20ab405abf1620f9eef482dabcc13e90977a83e Mon Sep 17 00:00:00 2001 From: Andrew Cholakian Date: Mon, 11 Jan 2016 10:02:15 -0600 Subject: [PATCH 1/2] Mark both client and server as not worker safe This is due to IO#select not being threadsafe in JRuby Fixes https://github.com/logstash-plugins/logstash-output-tcp/issues/13 --- CHANGELOG.md | 6 ++++-- lib/logstash/outputs/tcp.rb | 7 +++++-- logstash-output-tcp.gemspec | 3 +-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da34c73..6938ab1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 3.2.0 + - Declare plugin as not worker safe for both server and client mode. (IO#select is not threadsafe) + ## 3.1.0 - breaking,config: Remove deprecated config `message_format` @@ -14,7 +17,6 @@ - New dependency requirements for logstash-core for the 5.0 release ## 2.0.0 - - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully, + - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully, instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895 - Dependency on logstash-core update to 2.0 - diff --git a/lib/logstash/outputs/tcp.rb b/lib/logstash/outputs/tcp.rb index b61d4a7..8568af5 100644 --- a/lib/logstash/outputs/tcp.rb +++ b/lib/logstash/outputs/tcp.rb @@ -30,6 +30,8 @@ class LogStash::Outputs::Tcp < LogStash::Outputs::Base # `client` connects to a server. config :mode, :validate => ["server", "client"], :default => "client" + declare_workers_not_supported! + class Client public def initialize(socket, logger) @@ -61,9 +63,10 @@ def write(msg) def register require "socket" require "stud/try" - if server? - workers_not_supported + workers_not_supported + + if server? @logger.info("Starting tcp output listener", :address => "#{@host}:#{@port}") @server_socket = TCPServer.new(@host, @port) @client_threads = [] diff --git a/logstash-output-tcp.gemspec b/logstash-output-tcp.gemspec index 5540902..b2a7a48 100644 --- a/logstash-output-tcp.gemspec +++ b/logstash-output-tcp.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.name = 'logstash-output-tcp' - s.version = '3.1.0' + s.version = '3.2.0' s.licenses = ['Apache License (2.0)'] s.summary = "Write events over a TCP socket." 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" @@ -27,4 +27,3 @@ Gem::Specification.new do |s| s.add_development_dependency 'logstash-devutils' end - From 5c3e73d51a4a889a31634a1c5f4ef27162aeb28e Mon Sep 17 00:00:00 2001 From: Andrew Cholakian Date: Mon, 11 Jan 2016 10:04:39 -0600 Subject: [PATCH 2/2] Use travis for CI --- .travis.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5c63af6..1b46b43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,4 @@ rvm: script: - bundle exec rspec spec jdk: oraclejdk8 -before_install: [] +script: bundle exec rspec spec && bundle exec rspec spec --tag integration diff --git a/README.md b/README.md index 96c88c4..d7592d1 100644 --- a/README.md +++ b/README.md @@ -95,4 +95,4 @@ Programming is not a required skill. Whatever you've seen about open source and It is more important to the community that you are able to contribute. -For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file. \ No newline at end of file +For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.