mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
- Don't use EventMachine.defer for running message handlers. Turns out it's
faster if we don't push the call off to another thread.
This commit is contained in:
parent
42df5ba36b
commit
7b83c35eaf
1 changed files with 13 additions and 9 deletions
|
@ -33,15 +33,20 @@ module LogStash; module Net
|
|||
name = msg.class.name.split(":")[-1]
|
||||
func = "#{name}Handler"
|
||||
if @handler.respond_to?(func):
|
||||
operation = lambda do
|
||||
@handler.send(func, msg) do |response|
|
||||
sendmsg(response)
|
||||
end
|
||||
end
|
||||
EventMachine.defer(operation, nil)
|
||||
#@handler.send(func, msg) do |response|
|
||||
#sendmsg(response)
|
||||
#operation = lambda do
|
||||
#@handler.send(func, msg) do |response|
|
||||
#sendmsg(response)
|
||||
#end
|
||||
#end
|
||||
#EventMachine.defer(operation, nil)
|
||||
|
||||
# We actually get better performance if we don't defer processing
|
||||
# to another thread. This should be done carefully, though, as
|
||||
# blocking here will block the receiving thread for this socket
|
||||
# (maybe for all of eventmachine?).
|
||||
@handler.send(func, msg) do |response|
|
||||
sendmsg(response)
|
||||
end
|
||||
else
|
||||
$stderr.puts "#{@handler.class.name} does not support #{func}"
|
||||
end
|
||||
|
@ -50,7 +55,6 @@ module LogStash; module Net
|
|||
if len > 0
|
||||
puts "Removing #{len} bytes (#{count} packets)"
|
||||
@buffer[0 .. len - 1] = ""
|
||||
sleep 1
|
||||
end
|
||||
end # def receive_data
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue