From c2a0658fc26467a3950bb2848948932ae4f33f61 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 1 May 2018 19:42:22 +0000 Subject: tests: thread-safety fixes We can't require 'proxy_pass' in both a parent and forked child, so require it up front (as kcar will become a hard dependency in place of unicorn). Then, rely on GTL (global test lock) to synchronize around fork since the VM may not always be able to protect that. However, there's no need to synchronize around spawn/system/`backtick`, as the VM should always be using those in a thread-safe way (via vfork). --- test/test_proxy_pass.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'test/test_proxy_pass.rb') diff --git a/test/test_proxy_pass.rb b/test/test_proxy_pass.rb index 22f1802..51d0d3f 100644 --- a/test/test_proxy_pass.rb +++ b/test/test_proxy_pass.rb @@ -6,6 +6,7 @@ require 'json' require 'digest' begin require 'kcar' + require 'yahns/proxy_pass' rescue LoadError end @@ -188,7 +189,6 @@ class TestProxyPass < Testcase pid = mkserver(cfg) do @srv.autoclose = @srv2.autoclose = false ENV["YAHNS_FD"] = "#{@srv.fileno},#{@srv2.fileno}" - require 'yahns/proxy_pass' cfg.instance_eval do app(:rack, Yahns::ProxyPass.new("unix:#{unix_path}:/$fullpath")) do listen "#{host}:#{port}" @@ -251,7 +251,6 @@ class TestProxyPass < Testcase err, cfg, host, port = @err, Yahns::Config.new, @srv.addr[3], @srv.addr[1] host2, port2 = @srv2.addr[3], @srv2.addr[1] pid = mkserver(cfg) do - require 'yahns/proxy_pass' @srv2.close cfg.instance_eval do app(:rack, Yahns::ProxyPass.new("http://#{host2}:#{port2}")) do -- cgit v1.2.3-24-ge0c7