From 1f2ba4dca8c67442e19367ac7f1f96dbff6457ff Mon Sep 17 00:00:00 2001 From: Oisin Canty Date: Wed, 21 Jul 2021 14:53:33 +0000 Subject: Tests: use mutex with multitthreaded Ruby hooks. This commit fixes a rare crash that can occur when File.write is called by many threads. --- test/ruby/hooks/on_thread_boot.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'test/ruby/hooks/on_thread_boot.rb') 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 -- cgit