aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest/lib504.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-05-14 09:22:12 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-05-14 09:22:12 +0000
commite2e593a036c992f2d38e060e14b52c4a8862ca2d (patch)
tree69ce3c089381d03bd4f66792b2c994ddc0a13980 /tests/libtest/lib504.c
parent9ce0a7b49d4f004b7d55833a35feabbc8c27726f (diff)
clean up properly on failure to enable easier libcurl leak detection
Diffstat (limited to 'tests/libtest/lib504.c')
-rw-r--r--tests/libtest/lib504.c82
1 files changed, 42 insertions, 40 deletions
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);