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

cleanup class variable resources #2647

Merged
merged 1 commit into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/fluent/compat/call_super_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ def before_shutdown
end
end

def stop
klass = self.class
@@_super_start.delete(klass)
@@_super_before_shutdown.delete(klass)
@@_super_shutdown.delete(klass)

super
end

def shutdown
super
unless self.shutdown?
Expand Down
10 changes: 9 additions & 1 deletion lib/fluent/plugin/buf_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def initialize
@symlink_path = nil
@multi_workers_available = false
@additional_resume_path = nil
@buffer_path = nil
end

def configure(conf)
Expand All @@ -73,7 +74,8 @@ def configure(conf)
raise ConfigError, "Other '#{type_using_this_path}' plugin already use same buffer path: type = #{type_of_owner}, buffer path = #{@path}"
end

@@buffer_paths[@path] = type_of_owner
@buffer_path = @path
@@buffer_paths[@buffer_path] = type_of_owner

specified_directory_exists = File.exist?(@path) && File.directory?(@path)
unexisting_path_for_directory = !File.exist?(@path) && [email protected]?('.*')
Expand Down Expand Up @@ -122,6 +124,12 @@ def start
super
end

def stop
@@buffer_paths.delete(@buffer_path)

super
end

def persistent?
true
end
Expand Down
6 changes: 6 additions & 0 deletions lib/fluent/plugin/buf_file_single.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ def start
super
end

def stop
@@buffer_paths.delete(@path)

super
end

def persistent?
true
end
Expand Down
6 changes: 6 additions & 0 deletions lib/fluent/plugin/in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ def start
timer_execute(:in_tail_refresh_watchers, @refresh_interval, &method(:refresh_watchers))
end

def stop
@@pos_file_paths.delete(@pos_file)

super
end

def shutdown
# during shutdown phase, don't close io. It should be done in close after all threads are stopped. See close.
stop_watchers(@tails.keys, immediate: true, remove_watcher: false)
Expand Down
6 changes: 6 additions & 0 deletions lib/fluent/plugin_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,11 @@ def plugin_root_dir
@_plugin_root_dir = dir.freeze
dir
end

def stop
@@configured_ids.delete(@id)

super
end
end
end