diff options
author | Yang Tse <yangsita@gmail.com> | 2006-10-20 15:39:54 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2006-10-20 15:39:54 +0000 |
commit | b9ccecf86e96e173ffe3b4026c84e61e53d3ff68 (patch) | |
tree | 3ba2198ddda7a2880264fd4cb815969676c20cda /tests/libtest/lib536.c | |
parent | bd5d21aaf23cd20b74ad13e9d8ca16e81a4aea48 (diff) |
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.
Diffstat (limited to 'tests/libtest/lib536.c')
-rw-r--r-- | tests/libtest/lib536.c | 21 |
1 files changed, 18 insertions, 3 deletions
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 <sys/stat.h> #include <fcntl.h> +#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; |