libmicrohttpd

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

commit 7dce0363c4a99a36f7947d527175883a537e6193
parent a0060ee639310e960c6a2ab4b145708f544093af
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri, 23 Sep 2016 14:57:05 +0000

more select() return value checks in testcases

Diffstat:
Msrc/testcurl/perf_get.c | 22+++++++++++++---------
Msrc/testcurl/test_get.c | 6+++++-
Msrc/testcurl/test_get_chunked.c | 6+++++-
Msrc/testcurl/test_get_response_cleanup.c | 20++++++++++++++------
Msrc/testcurl/test_get_sendfile.c | 6+++++-
Msrc/testcurl/test_large_put.c | 12++++++++----
Msrc/testcurl/test_parse_cookies.c | 6+++++-
Msrc/testcurl/test_process_arguments.c | 6+++++-
8 files changed, 60 insertions(+), 24 deletions(-)

diff --git a/src/testcurl/perf_get.c b/src/testcurl/perf_get.c @@ -28,7 +28,7 @@ * so the performance scores calculated with this code * should NOT be used to compare with other HTTP servers * (since MHD is actually better); only the relative - * scores between MHD versions are meaningful. + * scores between MHD versions are meaningful. * Furthermore, this code ONLY tests MHD processing * a single request at a time. This is again * not universally meaningful (i.e. when comparing @@ -80,11 +80,11 @@ static unsigned long long start_time; /** - * Get the current timestamp + * Get the current timestamp * * @return current time in ms */ -static unsigned long long +static unsigned long long now () { struct timeval tv; @@ -98,7 +98,7 @@ now () /** * Start the timer. */ -static void +static void start_timer() { start_time = now (); @@ -110,7 +110,7 @@ start_timer() * * @param desc description of the threading mode we used */ -static void +static void stop (const char *desc) { double rps = ((double) (ROUNDS * 1000)) / ((double) (now() - start_time)); @@ -136,8 +136,8 @@ struct CBC static size_t -copyBuffer (void *ptr, - size_t size, size_t nmemb, +copyBuffer (void *ptr, + size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; @@ -346,7 +346,7 @@ testMultithreadedPoolGet (int port, int poll_flag) } curl_easy_cleanup (c); } - stop (0 != (poll_flag & MHD_USE_POLL) ? "thread pool with poll" : + stop (0 != (poll_flag & MHD_USE_POLL) ? "thread pool with poll" : 0 != (poll_flag & MHD_USE_EPOLL) ? "thread pool with epoll" : "thread pool with select"); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) @@ -451,7 +451,11 @@ testExternalGet (int port) } tv.tv_sec = 0; tv.tv_usec = 1000; - select (maxposixs + 1, &rs, &ws, &es, &tv); + if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) + { + if (EINTR != errno) + abort (); + } curl_multi_perform (multi, &running); if (running == 0) { diff --git a/src/testcurl/test_get.c b/src/testcurl/test_get.c @@ -357,7 +357,11 @@ testExternalGet () } tv.tv_sec = 0; tv.tv_usec = 1000; - select (maxposixs + 1, &rs, &ws, &es, &tv); + if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) + { + if (EINTR != errno) + abort (); + } curl_multi_perform (multi, &running); if (running == 0) { diff --git a/src/testcurl/test_get_chunked.c b/src/testcurl/test_get_chunked.c @@ -367,7 +367,11 @@ testExternalGet () } tv.tv_sec = 0; tv.tv_usec = 1000; - select (maxposixs + 1, &rs, &ws, &es, &tv); + if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) + { + if (EINTR != errno) + abort (); + } curl_multi_perform (multi, &running); if (running == 0) { diff --git a/src/testcurl/test_get_response_cleanup.c b/src/testcurl/test_get_response_cleanup.c @@ -71,10 +71,10 @@ fork_curl (const char *url) if (ret != 0) return ret; execlp ("curl", "curl", "-s", "-N", "-o", "/dev/null", "-GET", url, NULL); - fprintf (stderr, + fprintf (stderr, "Failed to exec curl: %s\n", strerror (errno)); - _exit (-1); + _exit (-1); } static void @@ -130,7 +130,7 @@ ahc_echo (void *cls, return MHD_YES; } *unused = NULL; - response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, + response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 32 * 1024, &push_callback, &ok, @@ -241,7 +241,7 @@ testExternalGet () if (d == NULL) return 256; curl = fork_curl ("http://127.0.0.1:1082/"); - + start = time (NULL); while ((time (NULL) - start < 2)) { @@ -256,7 +256,11 @@ testExternalGet () } tv.tv_sec = 0; tv.tv_usec = 1000; - select (max + 1, &rs, &ws, &es, &tv); + if (-1 == select (max + 1, &rs, &ws, &es, &tv)) + { + if (EINTR != errno) + abort (); + } MHD_run (d); } kill_curl (curl); @@ -274,7 +278,11 @@ testExternalGet () } tv.tv_sec = 0; tv.tv_usec = 1000; - select (max + 1, &rs, &ws, &es, &tv); + if (-1 == select (max + 1, &rs, &ws, &es, &tv)) + { + if (EINTR != errno) + abort (); + } MHD_run (d); } // fprintf (stderr, "Stopping daemon!\n"); diff --git a/src/testcurl/test_get_sendfile.c b/src/testcurl/test_get_sendfile.c @@ -355,7 +355,11 @@ testExternalGet () } tv.tv_sec = 0; tv.tv_usec = 1000; - select (maxposixs + 1, &rs, &ws, &es, &tv); + if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) + { + if (EINTR != errno) + abort (); + } curl_multi_perform (multi, &running); if (running == 0) { diff --git a/src/testcurl/test_large_put.c b/src/testcurl/test_large_put.c @@ -130,7 +130,7 @@ ahc_echo (void *cls, return MHD_YES; } response = MHD_create_response_from_buffer (strlen (url), - (void *) url, + (void *) url, MHD_RESPMEM_MUST_COPY); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); @@ -154,7 +154,7 @@ testInternalPut () cbc.pos = 0; d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, 1080, - NULL, NULL, &ahc_echo, &done_flag, + NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (1024*1024), MHD_OPTION_END); if (d == NULL) @@ -212,7 +212,7 @@ testMultithreadedPut () cbc.pos = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 1081, - NULL, NULL, &ahc_echo, &done_flag, + NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (1024*1024), MHD_OPTION_END); if (d == NULL) @@ -419,7 +419,11 @@ testExternalPut () } tv.tv_sec = 0; tv.tv_usec = 1000; - select (maxposixs + 1, &rs, &ws, &es, &tv); + if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) + { + if (EINTR != errno) + abort (); + } curl_multi_perform (multi, &running); if (running == 0) { diff --git a/src/testcurl/test_parse_cookies.c b/src/testcurl/test_parse_cookies.c @@ -201,7 +201,11 @@ testExternalGet () } tv.tv_sec = 0; tv.tv_usec = 1000; - select (maxposixs + 1, &rs, &ws, &es, &tv); + if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) + { + if (EINTR != errno) + abort (); + } curl_multi_perform (multi, &running); if (running == 0) { diff --git a/src/testcurl/test_process_arguments.c b/src/testcurl/test_process_arguments.c @@ -200,7 +200,11 @@ testExternalGet () } tv.tv_sec = 0; tv.tv_usec = 1000; - select (maxposixs + 1, &rs, &ws, &es, &tv); + if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) + { + if (EINTR != errno) + abort (); + } curl_multi_perform (multi, &running); if (running == 0) {