diff options
author | Oisin Canty <o.canty@f5.com> | 2021-07-21 14:53:33 +0000 |
---|---|---|
committer | Oisin Canty <o.canty@f5.com> | 2021-07-21 14:53:33 +0000 |
commit | 1f2ba4dca8c67442e19367ac7f1f96dbff6457ff (patch) | |
tree | 20bf57870180fb6b6f08e39067abec562479030a /test/ruby/hooks/on_thread_boot.rb | |
parent | f27fbd9b4d2bdaddf1e7001d0d0bc5586ba04cd4 (diff) | |
download | unit-1f2ba4dca8c67442e19367ac7f1f96dbff6457ff.tar.gz unit-1f2ba4dca8c67442e19367ac7f1f96dbff6457ff.tar.bz2 |
Tests: use mutex with multitthreaded Ruby hooks.
This commit fixes a rare crash that can occur when File.write is
called by many threads.
Diffstat (limited to 'test/ruby/hooks/on_thread_boot.rb')
-rw-r--r-- | test/ruby/hooks/on_thread_boot.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/test/ruby/hooks/on_thread_boot.rb b/test/ruby/hooks/on_thread_boot.rb index 1e05e248..4f88424e 100644 --- a/test/ruby/hooks/on_thread_boot.rb +++ b/test/ruby/hooks/on_thread_boot.rb @@ -1,5 +1,9 @@ require 'securerandom' +@mutex = Mutex.new + on_thread_boot do - File.write("./cookie_thread_boot.#{SecureRandom.hex}", "booted") + @mutex.synchronize do + File.write("./cookie_thread_boot.#{SecureRandom.hex}", "booted") + end end |