From ead6ab2ef765ec8c917ba8f5424d72a6624b0b20 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 19 Oct 2006 17:29:25 +0000 Subject: Abort test if it seems that it would have run forever. This is just to prevent test hanging and actually is an indication that there's a condition that is not being properly handled at some point in the library. Loop counter limits might need to be further increased on false positives. --- tests/libtest/lib504.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'tests/libtest/lib504.c') diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 843e9ebd0..fed91232c 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -20,7 +20,8 @@ int test(char *URL) int running; int max_fd; int rc; - int loop=10; + int loop1 = 10; + int loop2 = 20; curl_global_init(CURL_GLOBAL_ALL); c = curl_easy_init(); @@ -42,12 +43,15 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; + int loop2 = 20; fprintf(stderr, "curl_multi_perform()\n"); do { res = curl_multi_perform(m, &running); - } while (res == CURLM_CALL_MULTI_PERFORM); + } while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)); + if (loop2 <= 0) + break; if(!running) { /* This is where this code is expected to reach */ int numleft; @@ -82,7 +86,12 @@ int test(char *URL) /* we only allow a certain number of loops to avoid hanging here forever */ - } while(--loop>0); + } while(--loop1>0); + if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "ABORTING TEST, since it seems " + "that it would have run forever.\n"); + ret = 77; + } } curl_multi_remove_handle(m, c); -- cgit v1.2.3