Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

out_file: Revert #1995 changes #2842

Merged
merged 1 commit into from
Feb 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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