From e2e593a036c992f2d38e060e14b52c4a8862ca2d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 14 May 2004 09:22:12 +0000 Subject: clean up properly on failure to enable easier libcurl leak detection --- tests/libtest/lib504.c | 82 ++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 40 deletions(-) (limited to 'tests/libtest/lib504.c') diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 5f2c6acfc..df2e3ff2c 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -35,53 +35,55 @@ int test(char *URL) res = curl_multi_add_handle(m, c); if(res && (res != CURLM_CALL_MULTI_PERFORM)) - return 1; /* major failure */ - do { - struct timeval interval; + ; /* major failure */ + else { + do { + struct timeval interval; - interval.tv_sec = 1; - interval.tv_usec = 0; + interval.tv_sec = 1; + interval.tv_usec = 0; - fprintf(stderr, "curl_multi_perform()\n"); + fprintf(stderr, "curl_multi_perform()\n"); - do { - res = curl_multi_perform(m, &running); - } while (res == CURLM_CALL_MULTI_PERFORM); - if(!running) { - /* This is where this code is expected to reach */ - int numleft; - CURLMsg *msg = curl_multi_info_read(m, &numleft); - fprintf(stderr, "Expected: not running\n"); - if(msg && !numleft) - ret = 100; /* this is where we should be */ - else - ret = 99; /* not correct */ - break; - } - fprintf(stderr, "running == %d, res == %d\n", running, res); + do { + res = curl_multi_perform(m, &running); + } while (res == CURLM_CALL_MULTI_PERFORM); + if(!running) { + /* This is where this code is expected to reach */ + int numleft; + CURLMsg *msg = curl_multi_info_read(m, &numleft); + fprintf(stderr, "Expected: not running\n"); + if(msg && !numleft) + ret = 100; /* this is where we should be */ + else + ret = 99; /* not correct */ + break; + } + fprintf(stderr, "running == %d, res == %d\n", running, res); - if (res != CURLM_OK) { - ret = 2; - break; - } + if (res != CURLM_OK) { + ret = 2; + break; + } - FD_ZERO(&rd); - FD_ZERO(&wr); - FD_ZERO(&exc); - max_fd = 0; + FD_ZERO(&rd); + FD_ZERO(&wr); + FD_ZERO(&exc); + max_fd = 0; - fprintf(stderr, "curl_multi_fdset()\n"); - if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) { - fprintf(stderr, "unexpected failured of fdset.\n"); - ret = 3; - break; - } - rc = select(max_fd+1, &rd, &wr, &exc, &interval); - fprintf(stderr, "select returned %d\n", rc); + fprintf(stderr, "curl_multi_fdset()\n"); + if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) { + fprintf(stderr, "unexpected failured of fdset.\n"); + ret = 3; + break; + } + rc = select(max_fd+1, &rd, &wr, &exc, &interval); + fprintf(stderr, "select returned %d\n", rc); - /* we only allow a certain number of loops to avoid hanging here - forever */ - } while(rc && (--loop>0)); + /* we only allow a certain number of loops to avoid hanging here + forever */ + } while(rc && (--loop>0)); + } curl_multi_remove_handle(m, c); curl_easy_cleanup(c); -- cgit v1.2.3