зеркало из https://github.com/github/ruby.git
handle_interrupt to defend monitor state [Bug #15992]
If an exception is raised from another thread for example Timeout and this thread is just after `mon_exit`'s `@mon_owner = nil`, the exception breaks the state of MonitorMixin. To prevent that situation, it need to block interruption in mon_enter and mon_exit.
This commit is contained in:
Родитель
1d2ec4b216
Коммит
f91879a7b5
|
@ -225,11 +225,13 @@ module MonitorMixin
|
|||
# +MonitorMixin+.
|
||||
#
|
||||
def mon_synchronize
|
||||
mon_enter
|
||||
# Prevent interrupt on handling interrupts; for example timeout errors
|
||||
# it may break locking state.
|
||||
Thread.handle_interrupt(Exception => :never){ mon_enter }
|
||||
begin
|
||||
yield
|
||||
ensure
|
||||
mon_exit
|
||||
Thread.handle_interrupt(Exception => :never){ mon_exit }
|
||||
end
|
||||
end
|
||||
alias synchronize mon_synchronize
|
||||
|
|
Загрузка…
Ссылка в новой задаче