Skip to content

Commit

Permalink
Process chunks with buffer lock in enqueue_chunk
Browse files Browse the repository at this point in the history
In flush threads @buffer could call destructive
methods of chunks in @Queue without chunk lock,
so buffer lock is required.
  • Loading branch information
abicky committed Oct 21, 2017
1 parent ed9f921 commit 1a6f16b
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/fluent/plugin/buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,21 +319,19 @@ def enqueue_chunk(metadata)
return nil unless chunk

chunk.synchronize do
if chunk.empty?
chunk.close
else
synchronize do
synchronize do
if chunk.empty?
chunk.close
else
@queue << chunk
@queued_num[metadata] = @queued_num.fetch(metadata, 0) + 1
chunk.enqueued!
end
chunk.enqueued!
bytesize = chunk.bytesize
@stage_size -= bytesize
@queue_size += bytesize
end
end
bytesize = chunk.bytesize
synchronize do
@stage_size -= bytesize
@queue_size += bytesize
end
nil
end

Expand Down

0 comments on commit 1a6f16b

Please sign in to comment.