Skip to content

Commit

Permalink
out_file: Revert #1995 changes
Browse files Browse the repository at this point in the history
Recent fluentd doesn't have thread interruption issue.

Signed-off-by: Masahiro Nakagawa <repeatedly@gmail.com>
  • Loading branch information
repeatedly committed Feb 25, 2020
1 parent fb45d29 commit aee1767
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions lib/fluent/plugin/out_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
require 'fileutils'
require 'zlib'
require 'time'
require 'tempfile'

require 'fluent/plugin/output'
require 'fluent/config/error'
Expand Down Expand Up @@ -232,28 +231,10 @@ def write_without_compression(path, chunk)
end

def write_gzip_with_compression(path, chunk)
if @append
# This code will be removed after zlib/multithread bug is fixed.
# Use Tempfile to avoid broken gzip files: https://github.com/fluent/fluentd/issues/1903
Tempfile.create('out_file-gzip-append') { |temp|
begin
writer = Zlib::GzipWriter.new(temp)
chunk.write_to(writer, compressed: :text)
ensure
writer.finish # avoid zlib finalizer warning
end
temp.rewind

File.open(path, "ab", @file_perm) do |f|
IO.copy_stream(temp, f)
end
}
else
File.open(path, "ab", @file_perm) do |f|
gz = Zlib::GzipWriter.new(f)
chunk.write_to(gz, compressed: :text)
gz.close
end
File.open(path, "ab", @file_perm) do |f|
gz = Zlib::GzipWriter.new(f)
chunk.write_to(gz, compressed: :text)
gz.close
end
end

Expand Down

0 comments on commit aee1767

Please sign in to comment.