diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-09-23 14:57:05 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-09-23 14:57:05 +0000 |
commit | 7dce0363c4a99a36f7947d527175883a537e6193 (patch) | |
tree | 48c730c7504f8a8022785de5d72f15d5d2c6dbf9 | |
parent | a0060ee639310e960c6a2ab4b145708f544093af (diff) | |
download | libmicrohttpd-7dce0363c4a99a36f7947d527175883a537e6193.tar.gz libmicrohttpd-7dce0363c4a99a36f7947d527175883a537e6193.zip |
more select() return value checks in testcases
-rw-r--r-- | src/testcurl/perf_get.c | 22 | ||||
-rw-r--r-- | src/testcurl/test_get.c | 6 | ||||
-rw-r--r-- | src/testcurl/test_get_chunked.c | 6 | ||||
-rw-r--r-- | src/testcurl/test_get_response_cleanup.c | 20 | ||||
-rw-r--r-- | src/testcurl/test_get_sendfile.c | 6 | ||||
-rw-r--r-- | src/testcurl/test_large_put.c | 12 | ||||
-rw-r--r-- | src/testcurl/test_parse_cookies.c | 6 | ||||
-rw-r--r-- | src/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 index c39d9ec2..33783553 100644 --- a/src/testcurl/perf_get.c +++ b/src/testcurl/perf_get.c | |||
@@ -28,7 +28,7 @@ | |||
28 | * so the performance scores calculated with this code | 28 | * so the performance scores calculated with this code |
29 | * should NOT be used to compare with other HTTP servers | 29 | * should NOT be used to compare with other HTTP servers |
30 | * (since MHD is actually better); only the relative | 30 | * (since MHD is actually better); only the relative |
31 | * scores between MHD versions are meaningful. | 31 | * scores between MHD versions are meaningful. |
32 | * Furthermore, this code ONLY tests MHD processing | 32 | * Furthermore, this code ONLY tests MHD processing |
33 | * a single request at a time. This is again | 33 | * a single request at a time. This is again |
34 | * not universally meaningful (i.e. when comparing | 34 | * not universally meaningful (i.e. when comparing |
@@ -80,11 +80,11 @@ static unsigned long long start_time; | |||
80 | 80 | ||
81 | 81 | ||
82 | /** | 82 | /** |
83 | * Get the current timestamp | 83 | * Get the current timestamp |
84 | * | 84 | * |
85 | * @return current time in ms | 85 | * @return current time in ms |
86 | */ | 86 | */ |
87 | static unsigned long long | 87 | static unsigned long long |
88 | now () | 88 | now () |
89 | { | 89 | { |
90 | struct timeval tv; | 90 | struct timeval tv; |
@@ -98,7 +98,7 @@ now () | |||
98 | /** | 98 | /** |
99 | * Start the timer. | 99 | * Start the timer. |
100 | */ | 100 | */ |
101 | static void | 101 | static void |
102 | start_timer() | 102 | start_timer() |
103 | { | 103 | { |
104 | start_time = now (); | 104 | start_time = now (); |
@@ -110,7 +110,7 @@ start_timer() | |||
110 | * | 110 | * |
111 | * @param desc description of the threading mode we used | 111 | * @param desc description of the threading mode we used |
112 | */ | 112 | */ |
113 | static void | 113 | static void |
114 | stop (const char *desc) | 114 | stop (const char *desc) |
115 | { | 115 | { |
116 | double rps = ((double) (ROUNDS * 1000)) / ((double) (now() - start_time)); | 116 | double rps = ((double) (ROUNDS * 1000)) / ((double) (now() - start_time)); |
@@ -136,8 +136,8 @@ struct CBC | |||
136 | 136 | ||
137 | 137 | ||
138 | static size_t | 138 | static size_t |
139 | copyBuffer (void *ptr, | 139 | copyBuffer (void *ptr, |
140 | size_t size, size_t nmemb, | 140 | size_t size, size_t nmemb, |
141 | void *ctx) | 141 | void *ctx) |
142 | { | 142 | { |
143 | struct CBC *cbc = ctx; | 143 | struct CBC *cbc = ctx; |
@@ -346,7 +346,7 @@ testMultithreadedPoolGet (int port, int poll_flag) | |||
346 | } | 346 | } |
347 | curl_easy_cleanup (c); | 347 | curl_easy_cleanup (c); |
348 | } | 348 | } |
349 | stop (0 != (poll_flag & MHD_USE_POLL) ? "thread pool with poll" : | 349 | stop (0 != (poll_flag & MHD_USE_POLL) ? "thread pool with poll" : |
350 | 0 != (poll_flag & MHD_USE_EPOLL) ? "thread pool with epoll" : "thread pool with select"); | 350 | 0 != (poll_flag & MHD_USE_EPOLL) ? "thread pool with epoll" : "thread pool with select"); |
351 | MHD_stop_daemon (d); | 351 | MHD_stop_daemon (d); |
352 | if (cbc.pos != strlen ("/hello_world")) | 352 | if (cbc.pos != strlen ("/hello_world")) |
@@ -451,7 +451,11 @@ testExternalGet (int port) | |||
451 | } | 451 | } |
452 | tv.tv_sec = 0; | 452 | tv.tv_sec = 0; |
453 | tv.tv_usec = 1000; | 453 | tv.tv_usec = 1000; |
454 | select (maxposixs + 1, &rs, &ws, &es, &tv); | 454 | if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) |
455 | { | ||
456 | if (EINTR != errno) | ||
457 | abort (); | ||
458 | } | ||
455 | curl_multi_perform (multi, &running); | 459 | curl_multi_perform (multi, &running); |
456 | if (running == 0) | 460 | if (running == 0) |
457 | { | 461 | { |
diff --git a/src/testcurl/test_get.c b/src/testcurl/test_get.c index 19740042..6b21aa9e 100644 --- a/src/testcurl/test_get.c +++ b/src/testcurl/test_get.c | |||
@@ -357,7 +357,11 @@ testExternalGet () | |||
357 | } | 357 | } |
358 | tv.tv_sec = 0; | 358 | tv.tv_sec = 0; |
359 | tv.tv_usec = 1000; | 359 | tv.tv_usec = 1000; |
360 | select (maxposixs + 1, &rs, &ws, &es, &tv); | 360 | if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) |
361 | { | ||
362 | if (EINTR != errno) | ||
363 | abort (); | ||
364 | } | ||
361 | curl_multi_perform (multi, &running); | 365 | curl_multi_perform (multi, &running); |
362 | if (running == 0) | 366 | if (running == 0) |
363 | { | 367 | { |
diff --git a/src/testcurl/test_get_chunked.c b/src/testcurl/test_get_chunked.c index 003b6a58..297d9061 100644 --- a/src/testcurl/test_get_chunked.c +++ b/src/testcurl/test_get_chunked.c | |||
@@ -367,7 +367,11 @@ testExternalGet () | |||
367 | } | 367 | } |
368 | tv.tv_sec = 0; | 368 | tv.tv_sec = 0; |
369 | tv.tv_usec = 1000; | 369 | tv.tv_usec = 1000; |
370 | select (maxposixs + 1, &rs, &ws, &es, &tv); | 370 | if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) |
371 | { | ||
372 | if (EINTR != errno) | ||
373 | abort (); | ||
374 | } | ||
371 | curl_multi_perform (multi, &running); | 375 | curl_multi_perform (multi, &running); |
372 | if (running == 0) | 376 | if (running == 0) |
373 | { | 377 | { |
diff --git a/src/testcurl/test_get_response_cleanup.c b/src/testcurl/test_get_response_cleanup.c index c7335964..56b9b99e 100644 --- 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) | |||
71 | if (ret != 0) | 71 | if (ret != 0) |
72 | return ret; | 72 | return ret; |
73 | execlp ("curl", "curl", "-s", "-N", "-o", "/dev/null", "-GET", url, NULL); | 73 | execlp ("curl", "curl", "-s", "-N", "-o", "/dev/null", "-GET", url, NULL); |
74 | fprintf (stderr, | 74 | fprintf (stderr, |
75 | "Failed to exec curl: %s\n", | 75 | "Failed to exec curl: %s\n", |
76 | strerror (errno)); | 76 | strerror (errno)); |
77 | _exit (-1); | 77 | _exit (-1); |
78 | } | 78 | } |
79 | 79 | ||
80 | static void | 80 | static void |
@@ -130,7 +130,7 @@ ahc_echo (void *cls, | |||
130 | return MHD_YES; | 130 | return MHD_YES; |
131 | } | 131 | } |
132 | *unused = NULL; | 132 | *unused = NULL; |
133 | response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, | 133 | response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, |
134 | 32 * 1024, | 134 | 32 * 1024, |
135 | &push_callback, | 135 | &push_callback, |
136 | &ok, | 136 | &ok, |
@@ -241,7 +241,7 @@ testExternalGet () | |||
241 | if (d == NULL) | 241 | if (d == NULL) |
242 | return 256; | 242 | return 256; |
243 | curl = fork_curl ("http://127.0.0.1:1082/"); | 243 | curl = fork_curl ("http://127.0.0.1:1082/"); |
244 | 244 | ||
245 | start = time (NULL); | 245 | start = time (NULL); |
246 | while ((time (NULL) - start < 2)) | 246 | while ((time (NULL) - start < 2)) |
247 | { | 247 | { |
@@ -256,7 +256,11 @@ testExternalGet () | |||
256 | } | 256 | } |
257 | tv.tv_sec = 0; | 257 | tv.tv_sec = 0; |
258 | tv.tv_usec = 1000; | 258 | tv.tv_usec = 1000; |
259 | select (max + 1, &rs, &ws, &es, &tv); | 259 | if (-1 == select (max + 1, &rs, &ws, &es, &tv)) |
260 | { | ||
261 | if (EINTR != errno) | ||
262 | abort (); | ||
263 | } | ||
260 | MHD_run (d); | 264 | MHD_run (d); |
261 | } | 265 | } |
262 | kill_curl (curl); | 266 | kill_curl (curl); |
@@ -274,7 +278,11 @@ testExternalGet () | |||
274 | } | 278 | } |
275 | tv.tv_sec = 0; | 279 | tv.tv_sec = 0; |
276 | tv.tv_usec = 1000; | 280 | tv.tv_usec = 1000; |
277 | select (max + 1, &rs, &ws, &es, &tv); | 281 | if (-1 == select (max + 1, &rs, &ws, &es, &tv)) |
282 | { | ||
283 | if (EINTR != errno) | ||
284 | abort (); | ||
285 | } | ||
278 | MHD_run (d); | 286 | MHD_run (d); |
279 | } | 287 | } |
280 | // fprintf (stderr, "Stopping daemon!\n"); | 288 | // fprintf (stderr, "Stopping daemon!\n"); |
diff --git a/src/testcurl/test_get_sendfile.c b/src/testcurl/test_get_sendfile.c index d222a189..ed4d3466 100644 --- a/src/testcurl/test_get_sendfile.c +++ b/src/testcurl/test_get_sendfile.c | |||
@@ -355,7 +355,11 @@ testExternalGet () | |||
355 | } | 355 | } |
356 | tv.tv_sec = 0; | 356 | tv.tv_sec = 0; |
357 | tv.tv_usec = 1000; | 357 | tv.tv_usec = 1000; |
358 | select (maxposixs + 1, &rs, &ws, &es, &tv); | 358 | if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) |
359 | { | ||
360 | if (EINTR != errno) | ||
361 | abort (); | ||
362 | } | ||
359 | curl_multi_perform (multi, &running); | 363 | curl_multi_perform (multi, &running); |
360 | if (running == 0) | 364 | if (running == 0) |
361 | { | 365 | { |
diff --git a/src/testcurl/test_large_put.c b/src/testcurl/test_large_put.c index de635172..8b088be9 100644 --- a/src/testcurl/test_large_put.c +++ b/src/testcurl/test_large_put.c | |||
@@ -130,7 +130,7 @@ ahc_echo (void *cls, | |||
130 | return MHD_YES; | 130 | return MHD_YES; |
131 | } | 131 | } |
132 | response = MHD_create_response_from_buffer (strlen (url), | 132 | response = MHD_create_response_from_buffer (strlen (url), |
133 | (void *) url, | 133 | (void *) url, |
134 | MHD_RESPMEM_MUST_COPY); | 134 | MHD_RESPMEM_MUST_COPY); |
135 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 135 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
136 | MHD_destroy_response (response); | 136 | MHD_destroy_response (response); |
@@ -154,7 +154,7 @@ testInternalPut () | |||
154 | cbc.pos = 0; | 154 | cbc.pos = 0; |
155 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 155 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, |
156 | 1080, | 156 | 1080, |
157 | NULL, NULL, &ahc_echo, &done_flag, | 157 | NULL, NULL, &ahc_echo, &done_flag, |
158 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (1024*1024), | 158 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (1024*1024), |
159 | MHD_OPTION_END); | 159 | MHD_OPTION_END); |
160 | if (d == NULL) | 160 | if (d == NULL) |
@@ -212,7 +212,7 @@ testMultithreadedPut () | |||
212 | cbc.pos = 0; | 212 | cbc.pos = 0; |
213 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, | 213 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, |
214 | 1081, | 214 | 1081, |
215 | NULL, NULL, &ahc_echo, &done_flag, | 215 | NULL, NULL, &ahc_echo, &done_flag, |
216 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (1024*1024), | 216 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (1024*1024), |
217 | MHD_OPTION_END); | 217 | MHD_OPTION_END); |
218 | if (d == NULL) | 218 | if (d == NULL) |
@@ -419,7 +419,11 @@ testExternalPut () | |||
419 | } | 419 | } |
420 | tv.tv_sec = 0; | 420 | tv.tv_sec = 0; |
421 | tv.tv_usec = 1000; | 421 | tv.tv_usec = 1000; |
422 | select (maxposixs + 1, &rs, &ws, &es, &tv); | 422 | if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) |
423 | { | ||
424 | if (EINTR != errno) | ||
425 | abort (); | ||
426 | } | ||
423 | curl_multi_perform (multi, &running); | 427 | curl_multi_perform (multi, &running); |
424 | if (running == 0) | 428 | if (running == 0) |
425 | { | 429 | { |
diff --git a/src/testcurl/test_parse_cookies.c b/src/testcurl/test_parse_cookies.c index 613148aa..aefaafdf 100644 --- a/src/testcurl/test_parse_cookies.c +++ b/src/testcurl/test_parse_cookies.c | |||
@@ -201,7 +201,11 @@ testExternalGet () | |||
201 | } | 201 | } |
202 | tv.tv_sec = 0; | 202 | tv.tv_sec = 0; |
203 | tv.tv_usec = 1000; | 203 | tv.tv_usec = 1000; |
204 | select (maxposixs + 1, &rs, &ws, &es, &tv); | 204 | if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) |
205 | { | ||
206 | if (EINTR != errno) | ||
207 | abort (); | ||
208 | } | ||
205 | curl_multi_perform (multi, &running); | 209 | curl_multi_perform (multi, &running); |
206 | if (running == 0) | 210 | if (running == 0) |
207 | { | 211 | { |
diff --git a/src/testcurl/test_process_arguments.c b/src/testcurl/test_process_arguments.c index b5238043..0af578f8 100644 --- a/src/testcurl/test_process_arguments.c +++ b/src/testcurl/test_process_arguments.c | |||
@@ -200,7 +200,11 @@ testExternalGet () | |||
200 | } | 200 | } |
201 | tv.tv_sec = 0; | 201 | tv.tv_sec = 0; |
202 | tv.tv_usec = 1000; | 202 | tv.tv_usec = 1000; |
203 | select (maxposixs + 1, &rs, &ws, &es, &tv); | 203 | if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) |
204 | { | ||
205 | if (EINTR != errno) | ||
206 | abort (); | ||
207 | } | ||
204 | curl_multi_perform (multi, &running); | 208 | curl_multi_perform (multi, &running); |
205 | if (running == 0) | 209 | if (running == 0) |
206 | { | 210 | { |