From cf5ba246ac045101a591bbcba57027e7fc5f492b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 9 Nov 2009 13:58:36 -0800 Subject: tests: heartbeat-timeout: simplify and avoid possible race It seems possible to have a race condition here with the FIFO being overloaded for both start detection and blocking. Since SIGSTOP is unavoidable, just use that instead and sleep immediately afterwards in case SIGSTOP is not processed in time. --- t/heartbeat-timeout.ru | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 't/heartbeat-timeout.ru') diff --git a/t/heartbeat-timeout.ru b/t/heartbeat-timeout.ru index 471bddc..d9904e8 100644 --- a/t/heartbeat-timeout.ru +++ b/t/heartbeat-timeout.ru @@ -1,12 +1,10 @@ use Rack::ContentLength -fifo = ENV['FIFO_PATH'] or abort "FIFO_PATH not defined" headers = { 'Content-Type' => 'text/plain' } run lambda { |env| case env['PATH_INFO'] when "/block-forever" - # one of these should block forever Process.kill(:STOP, $$) - ::File.open(fifo, "rb") { |fp| fp.syswrite("NEVER\n") } + sleep # in case STOP signal is not received in time [ 500, headers, [ "Should never get here\n" ] ] else [ 200, headers, [ "#$$\n" ] ] -- cgit v1.2.3-24-ge0c7