Tests: use mutex with multitthreaded Ruby hooks.
This commit fixes a rare crash that can occur when File.write is called by many threads.
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
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
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
require 'securerandom'
|
||||
|
||||
@mutex = Mutex.new
|
||||
|
||||
on_thread_boot do
|
||||
@mutex.synchronize do
|
||||
File.write("./cookie_thread_boot.#{SecureRandom.hex}", "booted")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
require 'securerandom'
|
||||
|
||||
@mutex = Mutex.new
|
||||
|
||||
on_thread_shutdown do
|
||||
@mutex.synchronize do
|
||||
File.write("./cookie_thread_shutdown.#{SecureRandom.hex}", "shutdown")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user