-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix to wakeup threads to quit loop in threads #1264
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,7 @@ def thread_create(title) | |
thread_exit = true | ||
raise | ||
ensure | ||
unless thread_exit | ||
if ::Thread.current.alive? && !thread_exit | ||
log.warn "thread doesn't exit correctly (killed or other reason)", plugin: self.class, title: title, thread: ::Thread.current, error: $! | ||
end | ||
@_threads_mutex.synchronize do | ||
|
@@ -110,11 +110,31 @@ def initialize | |
|
||
def stop | ||
super | ||
wakeup_threads = [] | ||
@_threads_mutex.synchronize do | ||
@_threads.each_pair do |obj_id, thread| | ||
@_threads.values.each do |thread| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed to do so. |
||
thread[:_fluentd_plugin_helper_thread_running] = false | ||
wakeup_threads << thread if thread.alive? && thread.status == "sleep" | ||
end | ||
end | ||
wakeup_threads.each do |thread| | ||
if thread.alive? | ||
thread.wakeup | ||
end | ||
end | ||
end | ||
|
||
def after_shutdown | ||
super | ||
wakeup_threads = [] | ||
@_threads_mutex.synchronize do | ||
@_threads.values.each do |thread| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
wakeup_threads << thread if thread.alive? && thread.status == "sleep" | ||
end | ||
end | ||
wakeup_threads.each do |thread| | ||
thread.wakeup if thread.alive? | ||
end | ||
end | ||
|
||
def close | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to check
status
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to do so. Living threads are running or sleeping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see