mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
Use 'Interrupted' instead of IOError for interrupts
This commit is contained in:
parent
313e78e200
commit
8ac413a792
1 changed files with 8 additions and 6 deletions
|
@ -11,6 +11,7 @@ require "timeout"
|
|||
# Can either accept connections from clients or connect to a server,
|
||||
# depending on `mode`.
|
||||
class LogStash::Inputs::Tcp < LogStash::Inputs::Base
|
||||
class Interrupted < StandardError; end
|
||||
|
||||
config_name "tcp"
|
||||
plugin_status "beta"
|
||||
|
@ -73,8 +74,6 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
|
|||
:client => socket.peer)
|
||||
end # begin
|
||||
|
||||
rescue IOError
|
||||
# nothing
|
||||
ensure
|
||||
begin
|
||||
socket.close
|
||||
|
@ -108,10 +107,13 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
|
|||
s.instance_eval { class << self; include ::LogStash::Util::SocketPeer end }
|
||||
@logger.debug("Accepted connection", :client => s.peer,
|
||||
:server => "#{@host}:#{@port}")
|
||||
handle_socket(s, output_queue, "tcp://#{s.peer}/")
|
||||
|
||||
begin
|
||||
handle_socket(s, output_queue, "tcp://#{s.peer}/")
|
||||
rescue Interrupted
|
||||
s.close rescue nil
|
||||
end
|
||||
end # Thread.start
|
||||
rescue IOError
|
||||
rescue IOError, Interrupted
|
||||
if @interrupted
|
||||
# Intended shutdown, get out of the loop
|
||||
@server_socket.close
|
||||
|
@ -139,7 +141,7 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
|
|||
def teardown
|
||||
if server?
|
||||
@interrupted = true
|
||||
@thread.raise(IOError.new)
|
||||
@thread.raise(Interrupted.new)
|
||||
end
|
||||
end # def teardown
|
||||
end # class LogStash::Inputs::Tcp
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue