diff options
author | NARUSE, Yui <[email protected]> | 2019-07-10 15:49:10 +0900 |
---|---|---|
committer | NARUSE, Yui <[email protected]> | 2019-07-10 18:13:38 +0900 |
commit | f91879a7b548284c93743168acfd11e3d2aeefac (patch) | |
tree | 69fed5cf2dee4d3d59ce87e89c5ae77cc80183f4 /lib/monitor.rb | |
parent | 1d2ec4b21647089598d0be3a8bc5f56a71b5e892 (diff) |
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.
Diffstat (limited to 'lib/monitor.rb')
-rw-r--r-- | lib/monitor.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/monitor.rb b/lib/monitor.rb index 90847cf330..044219bcbb 100644 --- a/lib/monitor.rb +++ b/lib/monitor.rb @@ -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 |