From b9ccecf86e96e173ffe3b4026c84e61e53d3ff68 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 20 Oct 2006 15:39:54 +0000 Subject: Decrease the posibility of aborting a test which actually is not stale by replacing loop counters with timeouts. In this way the main loop of the test will be allowed to run up to 30 seconds on any platform before aborting it. --- tests/libtest/lib536.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'tests/libtest/lib536.c') diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 2e7874051..4181b829c 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -14,6 +14,11 @@ #include #include +#include "timeval.h" + +#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 + static CURLMcode perform(CURLM * multi); static CURLMcode perform(CURLM * multi) @@ -21,10 +26,19 @@ static CURLMcode perform(CURLM * multi) int handles, maxfd; CURLMcode code; fd_set fdread, fdwrite, fdexcep; - int loop; + struct timeval mp_start; + char mp_timedout = FALSE; - for (loop=40;loop>0;loop--) { + mp_timedout = FALSE; + mp_start = curlx_tvnow(); + + for (;;) { code = curl_multi_perform(multi, &handles); + if (curlx_tvdiff(curlx_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; + } if (handles <= 0) return CURLM_OK; @@ -47,7 +61,8 @@ static CURLMcode perform(CURLM * multi) return (CURLMcode) ~CURLM_OK; } - /* We only reach this point if (loop <= 0) */ + /* We only reach this point if (mp_timedout) */ + fprintf(stderr, "mp_timedout\n"); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); return (CURLMcode) ~CURLM_OK; -- cgit v1.2.3