From 7e0dc42f7084e1719456a80b2e44049133c2e8b7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 20 Dec 2010 00:54:17 +0000 Subject: thread_timeout: fix bad comparison This was causing unrelated requests to get killed every +timeout+ seconds, instead of only the ones that were running too long. Noticed-by: ghazel@gmail.com ref: http://mid.gmane.org/AANLkTi=7OhyTwkHsp_rXU7Gp1PokihiQ9bJigpO-BfN6@mail.gmail.com --- t/t9100-thread-timeout.sh | 22 +++++++++++++++++++++- t/t9101-thread-timeout-threshold.sh | 15 +++------------ 2 files changed, 24 insertions(+), 13 deletions(-) (limited to 't') diff --git a/t/t9100-thread-timeout.sh b/t/t9100-thread-timeout.sh index ab46e5a..0f802dd 100755 --- a/t/t9100-thread-timeout.sh +++ b/t/t9100-thread-timeout.sh @@ -5,7 +5,7 @@ ThreadSpawn|ThreadPool|RevThreadSpawn|RevThreadPool) ;; *) t_info "$0 is only compatible with Thread*"; exit 0 ;; esac -t_plan 5 "ThreadTimeout Rack middleware test for $model" +t_plan 6 "ThreadTimeout Rack middleware test for $model" t_begin "configure and start" && { rtmpfiles curl_err @@ -25,6 +25,26 @@ t_begin "sleepy request times out with 408" && { grep 408 $curl_err } +t_begin "short requests do not timeout while making a long one" && { + rm -f $ok $curl_err + > $ok + curl -sSf http://$listen/2 2>$curl_err >/dev/null & + ( + for i in $(awk =0;)print i}') + do + curl -sSf http://$listen/0.1 >> $ok 2>&1 & + test x"HI" = x"$(curl -sSf http://$listen/0.05)" + done + wait + ) + test x"HI" = x"$(curl -sSf http://$listen/)" + wait + test -f $ok + test 20 -eq $(grep '^HI$' $ok | wc -l) + test x = x"$(grep -v '^HI$' $ok)" + grep 408 $curl_err +} + t_begin "kill server" && { kill $rainbows_pid } diff --git a/t/t9101-thread-timeout-threshold.sh b/t/t9101-thread-timeout-threshold.sh index 1979dba..99d3f98 100755 --- a/t/t9101-thread-timeout-threshold.sh +++ b/t/t9101-thread-timeout-threshold.sh @@ -30,25 +30,16 @@ t_begin "8 sleepy requests do not time out" && { test xHI = x"$(sort < $curl_out | uniq)" } -t_begin "9 sleepy requests do time out" && { +t_begin "9 sleepy requests, some time out" && { > $curl_err > $curl_out for i in 1 2 3 4 5 6 7 8 9 do - rtmpfiles curl_err_$i curl -sSf --no-buffer \ - http://$listen/3 2>> ${curl_err}_${i} >> $curl_out & + http://$listen/3 2>> $curl_err >> $curl_out & done wait - if test -s $curl_out - then - dbgcat curl_out - die "$curl_out should be empty" - fi - for i in 1 2 3 4 5 6 7 8 9 - do - grep 408 ${curl_err}_${i} - done + grep 408 $curl_err } t_begin "kill server" && { -- cgit v1.2.3-24-ge0c7