libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit b812b174c3b4da28a93e3300064d63dd865b2178
parent 303d42fdcd8f029f4bf3cfb6401aec407c1626f4
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Mon, 16 Aug 2021 19:30:25 +0300

tests: improved handling of curl multi_*

Diffstat:
Msrc/testcurl/https/test_empty_response.c | 43++++++++++++++++++++++++++++---------------
Msrc/testcurl/https/test_https_get_select.c | 43++++++++++++++++++++++++++++---------------
Msrc/testcurl/perf_get.c | 48+++++++++++++++++++++++++++++++-----------------
Msrc/testcurl/test_callback.c | 16+++++++++-------
Msrc/testcurl/test_delete.c | 43++++++++++++++++++++++++++++---------------
Msrc/testcurl/test_get.c | 43++++++++++++++++++++++++++++---------------
Msrc/testcurl/test_get_chunked.c | 47++++++++++++++++++++++++++++++-----------------
Msrc/testcurl/test_get_empty.c | 43++++++++++++++++++++++++++++---------------
Msrc/testcurl/test_get_iovec.c | 43++++++++++++++++++++++++++++---------------
Msrc/testcurl/test_get_sendfile.c | 43++++++++++++++++++++++++++++---------------
Msrc/testcurl/test_large_put.c | 43++++++++++++++++++++++++++++---------------
Msrc/testcurl/test_parse_cookies.c | 43++++++++++++++++++++++++++++---------------
Msrc/testcurl/test_patch.c | 43++++++++++++++++++++++++++++---------------
Msrc/testcurl/test_post.c | 43++++++++++++++++++++++++++++---------------
Msrc/testcurl/test_post_loop.c | 42++++++++++++++++++++++++++++--------------
Msrc/testcurl/test_postform.c | 44++++++++++++++++++++++++++++----------------
Msrc/testcurl/test_process_arguments.c | 43++++++++++++++++++++++++++++---------------
Msrc/testcurl/test_process_headers.c | 43++++++++++++++++++++++++++++---------------
Msrc/testcurl/test_put.c | 43++++++++++++++++++++++++++++---------------
Msrc/testcurl/test_put_chunked.c | 44++++++++++++++++++++++++++++----------------
Msrc/testcurl/test_quiesce.c | 53++++++++++++++++++++++++++++++++---------------------
21 files changed, 578 insertions(+), 318 deletions(-)

diff --git a/src/testcurl/https/test_empty_response.c b/src/testcurl/https/test_empty_response.c @@ -189,24 +189,37 @@ testInternalSelectGet () else (void) sleep (1); curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } } if (multi != NULL) diff --git a/src/testcurl/https/test_https_get_select.c b/src/testcurl/https/test_https_get_select.c @@ -213,24 +213,37 @@ testExternalGet (int flags) else (void) sleep (1); curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/perf_get.c b/src/testcurl/perf_get.c @@ -225,7 +225,7 @@ testInternalGet (int port, int poll_flag) "http://127.0.0.1:%d/hello_world", port); start_timer (); - for (i = 0; i<ROUNDS; i++) + for (i = 0; i < ROUNDS; i++) { cbc.pos = 0; c = curl_easy_init (); @@ -304,7 +304,7 @@ testMultithreadedGet (int port, int poll_flag) "http://127.0.0.1:%d/hello_world", port); start_timer (); - for (i = 0; i<ROUNDS; i++) + for (i = 0; i < ROUNDS; i++) { cbc.pos = 0; c = curl_easy_init (); @@ -387,7 +387,7 @@ testMultithreadedPoolGet (int port, int poll_flag) "http://127.0.0.1:%d/hello_world", port); start_timer (); - for (i = 0; i<ROUNDS; i++) + for (i = 0; i < ROUNDS; i++) { cbc.pos = 0; c = curl_easy_init (); @@ -487,7 +487,7 @@ testExternalGet (int port) MHD_stop_daemon (d); return 512; } - for (i = 0; i<ROUNDS; i++) + for (i = 0; i < ROUNDS; i++) { cbc.pos = 0; c = curl_easy_init (); @@ -556,22 +556,36 @@ testExternalGet (int port) #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_easy_cleanup (c); - c = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_easy_cleanup (c); + c = NULL; + break; } /* two possibilities here; as select sets are tiny, this makes virtually no difference diff --git a/src/testcurl/test_callback.c b/src/testcurl/test_callback.c @@ -220,7 +220,7 @@ main (int argc, char **argv) abort (); #else if ((WSAEINVAL != WSAGetLastError ()) || - (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) + (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count)) abort (); Sleep (1000); #endif @@ -228,24 +228,26 @@ main (int argc, char **argv) if (NULL != multi) { curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->msg != CURLMSG_DONE) + if (msg->msg == CURLMSG_DONE) { - if (msg->data.result != CURLE_OK) + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); - abort (); + abort (); + } } - else - curl_fine = 1; } if (! curl_fine) { diff --git a/src/testcurl/test_delete.c b/src/testcurl/test_delete.c @@ -482,24 +482,37 @@ testExternalDelete () #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_get.c b/src/testcurl/test_get.c @@ -519,24 +519,37 @@ testExternalGet () #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_get_chunked.c b/src/testcurl/test_get_chunked.c @@ -686,26 +686,39 @@ testExternalGet () #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - curl_slist_free_all (h_list); - h_list = NULL; - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + curl_slist_free_all (h_list); + h_list = NULL; + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_get_empty.c b/src/testcurl/test_get_empty.c @@ -481,24 +481,37 @@ testExternalGet () #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_get_iovec.c b/src/testcurl/test_get_iovec.c @@ -603,24 +603,37 @@ testExternalGet () #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_get_sendfile.c b/src/testcurl/test_get_sendfile.c @@ -460,24 +460,37 @@ testExternalGet () #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_large_put.c b/src/testcurl/test_large_put.c @@ -576,24 +576,37 @@ testPutExternal (void) #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_parse_cookies.c b/src/testcurl/test_parse_cookies.c @@ -239,24 +239,37 @@ testExternalGet () #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_patch.c b/src/testcurl/test_patch.c @@ -450,24 +450,37 @@ testExternalPut () #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_post.c b/src/testcurl/test_post.c @@ -526,24 +526,37 @@ testExternalPost () #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_post_loop.c b/src/testcurl/test_post_loop.c @@ -519,7 +519,7 @@ testExternalPost () if ((CURLM_OK == curl_multi_timeout (multi, &ctimeout)) && (ctimeout < (long long) timeout) && (ctimeout >= 0)) timeout = ctimeout; - if ( (c == NULL) || (running == 0) ) + if ( (c == NULL) || (0 == running) ) timeout = 0; /* terminate quickly... */ tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout % 1000) * 1000; @@ -535,22 +535,36 @@ testExternalPost () while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform (multi, &running)) ; - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_easy_cleanup (c); - c = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_easy_cleanup (c); + c = NULL; + break; } MHD_run (d); } diff --git a/src/testcurl/test_postform.c b/src/testcurl/test_postform.c @@ -551,25 +551,37 @@ testExternalPost () #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, - curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_process_arguments.c b/src/testcurl/test_process_arguments.c @@ -238,24 +238,37 @@ testExternalGet () #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_process_headers.c b/src/testcurl/test_process_headers.c @@ -494,24 +494,37 @@ testExternalGet () #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_put.c b/src/testcurl/test_put.c @@ -494,24 +494,37 @@ testExternalPut () #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_put_chunked.c b/src/testcurl/test_put_chunked.c @@ -489,25 +489,37 @@ testExternalPut () #endif } curl_multi_perform (multi, &running); - if (running == 0) + if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (msg == NULL) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if (msg->data.result != CURLE_OK) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, - curl_easy_strerror (msg->data.result)); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + abort (); + } + } } + if (! curl_fine) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; } MHD_run (d); } diff --git a/src/testcurl/test_quiesce.c b/src/testcurl/test_quiesce.c @@ -469,29 +469,40 @@ testExternalGet () curl_multi_perform (multi, &running); if (0 == running) { - msg = curl_multi_info_read (multi, &running); - if (NULL == msg) - break; - if (msg->msg == CURLMSG_DONE) + int pending; + int curl_fine = 0; + while (NULL != (msg = curl_multi_info_read (multi, &pending))) { - if ((i == 0) && (msg->data.result != CURLE_OK) ) - printf ("%s failed at %s:%d: `%s'\n", - "curl_multi_perform", - __FILE__, - __LINE__, - curl_easy_strerror (msg->data.result)); - else if ( (i == 1) && - (msg->data.result == CURLE_OK) ) - printf ("%s should have failed at %s:%d\n", - "curl_multi_perform", - __FILE__, - __LINE__); - curl_multi_remove_handle (multi, c); - curl_multi_cleanup (multi); - curl_easy_cleanup (c); - c = NULL; - multi = NULL; + if (msg->msg == CURLMSG_DONE) + { + if (msg->data.result == CURLE_OK) + curl_fine = 1; + else if (i == 0) + { + fprintf (stderr, + "%s failed at %s:%d: `%s'\n", + "curl_multi_perform", + __FILE__, + __LINE__, curl_easy_strerror (msg->data.result)); + } + } } + if ((i == 0) && (! curl_fine)) + { + fprintf (stderr, "libcurl haven't returned OK code\n"); + abort (); + } + else if ((i == 1) && (curl_fine)) + { + fprintf (stderr, "libcurl returned OK code, while it shouldn't\n"); + abort (); + } + curl_multi_remove_handle (multi, c); + curl_multi_cleanup (multi); + curl_easy_cleanup (c); + c = NULL; + multi = NULL; + break; } MHD_run (d); }