Files
nginx-unit/test/ruby/hooks/multiple.rb
Oisin Canty 1f2ba4dca8 Tests: use mutex with multitthreaded Ruby hooks.
This commit fixes a rare crash that can occur when File.write is
called by many threads.
2021-07-21 14:53:33 +00:00

14 lines
279 B
Ruby

require 'securerandom'
@mutex = Mutex.new
on_worker_boot do
File.write("./cookie_worker_boot.#{SecureRandom.hex}", "worker booted")
end
on_thread_boot do
@mutex.synchronize do
File.write("./cookie_thread_boot.#{SecureRandom.hex}", "thread booted")
end
end