From a9bb8689e28b094258d48480c60b1eda5911c979 Mon Sep 17 00:00:00 2001 From: Jordan Sissel Date: Sun, 15 Sep 2013 22:53:34 -0700 Subject: [PATCH] - Pipeline now calls teardown on all input plugins when shutdown is requested - Make udp input plugin abort when shutdown signal is given. (LOGSTASH-1290) --- CHANGELOG | 3 +++ lib/logstash/inputs/udp.rb | 9 +++++++-- lib/logstash/pipeline.rb | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d436eed72..4a4819bd5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ 1.2.2 (???) # general + ## inputs + - bugfix: udp: respects teardown requests (via SIGINT) (LOGSTASH-1290) + ## filters - bugfix: geoip: empty values (nil, empty string) are not put into the event anymore. diff --git a/lib/logstash/inputs/udp.rb b/lib/logstash/inputs/udp.rb index 59a0c7592..2b58f5055 100644 --- a/lib/logstash/inputs/udp.rb +++ b/lib/logstash/inputs/udp.rb @@ -37,6 +37,8 @@ class LogStash::Inputs::Udp < LogStash::Inputs::Base begin # udp server udp_listener(output_queue) + rescue LogStash::ShutdownSignal + # do nothing, shutdown was requested. rescue => e @logger.warn("UDP listener died", :exception => e, :backtrace => e.backtrace) sleep(5) @@ -63,8 +65,6 @@ class LogStash::Inputs::Udp < LogStash::Inputs::Base output_queue << event end end - rescue LogStash::ShutdownSignal - # shutdown ensure if @udp @udp.close_read rescue nil @@ -72,4 +72,9 @@ class LogStash::Inputs::Udp < LogStash::Inputs::Base end end # def udp_listener + public + def teardown + @udp.close if @udp && !@udp.closed? + end + end # class LogStash::Inputs::Udp diff --git a/lib/logstash/pipeline.rb b/lib/logstash/pipeline.rb index 5e00397a6..42dd2dc7f 100644 --- a/lib/logstash/pipeline.rb +++ b/lib/logstash/pipeline.rb @@ -227,6 +227,9 @@ class LogStash::Pipeline thread.wakeup # in case it's in blocked IO or sleeping rescue ThreadError end + @inputs.each do |input| + input.teardown + end end # No need to send the ShutdownSignal to the filters/outputs nor to wait for