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'
|
require 'securerandom'
|
||||||
|
|
||||||
|
@mutex = Mutex.new
|
||||||
|
|
||||||
on_worker_boot do
|
on_worker_boot do
|
||||||
File.write("./cookie_worker_boot.#{SecureRandom.hex}", "worker booted")
|
File.write("./cookie_worker_boot.#{SecureRandom.hex}", "worker booted")
|
||||||
end
|
end
|
||||||
|
|
||||||
on_thread_boot do
|
on_thread_boot do
|
||||||
|
@mutex.synchronize do
|
||||||
File.write("./cookie_thread_boot.#{SecureRandom.hex}", "thread booted")
|
File.write("./cookie_thread_boot.#{SecureRandom.hex}", "thread booted")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
require 'securerandom'
|
require 'securerandom'
|
||||||
|
|
||||||
|
@mutex = Mutex.new
|
||||||
|
|
||||||
on_thread_boot do
|
on_thread_boot do
|
||||||
|
@mutex.synchronize do
|
||||||
File.write("./cookie_thread_boot.#{SecureRandom.hex}", "booted")
|
File.write("./cookie_thread_boot.#{SecureRandom.hex}", "booted")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
require 'securerandom'
|
require 'securerandom'
|
||||||
|
|
||||||
|
@mutex = Mutex.new
|
||||||
|
|
||||||
on_thread_shutdown do
|
on_thread_shutdown do
|
||||||
|
@mutex.synchronize do
|
||||||
File.write("./cookie_thread_shutdown.#{SecureRandom.hex}", "shutdown")
|
File.write("./cookie_thread_shutdown.#{SecureRandom.hex}", "shutdown")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user