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/lib509.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'tests/libtest/lib509.c') diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 415208ac7..9327d728f 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -175,6 +175,9 @@ int test(char *URL) int i = 0; CURLMsg *msg; + int loop1 = 40; + int loop2 = 20; + if(arg2) { portnum = atoi(arg2); } @@ -205,15 +208,16 @@ int test(char *URL) res = curl_multi_add_handle(multi, p.curl); - while(!done) { + while ((--loop1>0) && (loop2>0) && (!done)) { fd_set rd, wr, exc; int max_fd; struct timeval interval; interval.tv_sec = 1; interval.tv_usec = 0; + loop2 = 20; - while (res == CURLM_CALL_MULTI_PERFORM) { + while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)) { res = curl_multi_perform(multi, &running); fprintf(stderr, "running=%d res=%d\n",running,res); if (running <= 0) { @@ -221,7 +225,7 @@ int test(char *URL) break; } } - if(done) + if ((loop2 <= 0) || (done)) break; if (res != CURLM_OK) { @@ -249,13 +253,23 @@ int test(char *URL) res = CURLM_CALL_MULTI_PERFORM; } - msg = curl_multi_info_read(multi, &running); - /* this should now contain a result code from the easy handle, get it */ - if(msg) - i = msg->data.result; + + if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "ABORTING TEST, since it seems " + "that it would have run forever.\n"); + i = 77; + } + else { + msg = curl_multi_info_read(multi, &running); + /* this should now contain a result code from the easy handle, get it */ + if(msg) + i = msg->data.result; + } } - fprintf(stderr, "all done\n"); + if ((loop1>0) && (loop2>0)) { + fprintf(stderr, "all done\n"); + } curl_multi_remove_handle(multi, p.curl); curl_easy_cleanup(p.curl); -- cgit v1.2.3