diff options
Diffstat (limited to 'src/testcurl/test_post_loop.c')
-rw-r--r-- | src/testcurl/test_post_loop.c | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/src/testcurl/test_post_loop.c b/src/testcurl/test_post_loop.c index efcd5370..8a7e0d05 100644 --- a/src/testcurl/test_post_loop.c +++ b/src/testcurl/test_post_loop.c | |||
@@ -117,7 +117,7 @@ ahc_echo (void *cls, | |||
117 | } | 117 | } |
118 | 118 | ||
119 | 119 | ||
120 | static int | 120 | static unsigned int |
121 | testInternalPost (void) | 121 | testInternalPost (void) |
122 | { | 122 | { |
123 | struct MHD_Daemon *d; | 123 | struct MHD_Daemon *d; |
@@ -127,7 +127,7 @@ testInternalPost (void) | |||
127 | CURLcode errornum; | 127 | CURLcode errornum; |
128 | int i; | 128 | int i; |
129 | char url[1024]; | 129 | char url[1024]; |
130 | int port; | 130 | uint16_t port; |
131 | 131 | ||
132 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | 132 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) |
133 | port = 0; | 133 | port = 0; |
@@ -152,7 +152,7 @@ testInternalPost (void) | |||
152 | { | 152 | { |
153 | MHD_stop_daemon (d); return 32; | 153 | MHD_stop_daemon (d); return 32; |
154 | } | 154 | } |
155 | port = (int) dinfo->port; | 155 | port = dinfo->port; |
156 | } | 156 | } |
157 | for (i = 0; i < LOOPCOUNT; i++) | 157 | for (i = 0; i < LOOPCOUNT; i++) |
158 | { | 158 | { |
@@ -163,8 +163,8 @@ testInternalPost (void) | |||
163 | buf[0] = '\0'; | 163 | buf[0] = '\0'; |
164 | snprintf (url, | 164 | snprintf (url, |
165 | sizeof (url), | 165 | sizeof (url), |
166 | "http://127.0.0.1:%d/hw%d", | 166 | "http://127.0.0.1:%u/hw%d", |
167 | port, | 167 | (unsigned int) port, |
168 | i); | 168 | i); |
169 | curl_easy_setopt (c, CURLOPT_URL, url); | 169 | curl_easy_setopt (c, CURLOPT_URL, url); |
170 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 170 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
@@ -206,7 +206,7 @@ testInternalPost (void) | |||
206 | } | 206 | } |
207 | 207 | ||
208 | 208 | ||
209 | static int | 209 | static unsigned int |
210 | testMultithreadedPost (void) | 210 | testMultithreadedPost (void) |
211 | { | 211 | { |
212 | struct MHD_Daemon *d; | 212 | struct MHD_Daemon *d; |
@@ -216,7 +216,7 @@ testMultithreadedPost (void) | |||
216 | CURLcode errornum; | 216 | CURLcode errornum; |
217 | int i; | 217 | int i; |
218 | char url[1024]; | 218 | char url[1024]; |
219 | int port; | 219 | uint16_t port; |
220 | 220 | ||
221 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | 221 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) |
222 | port = 0; | 222 | port = 0; |
@@ -244,7 +244,7 @@ testMultithreadedPost (void) | |||
244 | { | 244 | { |
245 | MHD_stop_daemon (d); return 32; | 245 | MHD_stop_daemon (d); return 32; |
246 | } | 246 | } |
247 | port = (int) dinfo->port; | 247 | port = dinfo->port; |
248 | } | 248 | } |
249 | for (i = 0; i < LOOPCOUNT; i++) | 249 | for (i = 0; i < LOOPCOUNT; i++) |
250 | { | 250 | { |
@@ -255,8 +255,8 @@ testMultithreadedPost (void) | |||
255 | buf[0] = '\0'; | 255 | buf[0] = '\0'; |
256 | snprintf (url, | 256 | snprintf (url, |
257 | sizeof (url), | 257 | sizeof (url), |
258 | "http://127.0.0.1:%d/hw%d", | 258 | "http://127.0.0.1:%u/hw%d", |
259 | port, | 259 | (unsigned int) port, |
260 | i); | 260 | i); |
261 | curl_easy_setopt (c, CURLOPT_URL, url); | 261 | curl_easy_setopt (c, CURLOPT_URL, url); |
262 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 262 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
@@ -298,7 +298,7 @@ testMultithreadedPost (void) | |||
298 | } | 298 | } |
299 | 299 | ||
300 | 300 | ||
301 | static int | 301 | static unsigned int |
302 | testMultithreadedPoolPost (void) | 302 | testMultithreadedPoolPost (void) |
303 | { | 303 | { |
304 | struct MHD_Daemon *d; | 304 | struct MHD_Daemon *d; |
@@ -308,7 +308,7 @@ testMultithreadedPoolPost (void) | |||
308 | CURLcode errornum; | 308 | CURLcode errornum; |
309 | int i; | 309 | int i; |
310 | char url[1024]; | 310 | char url[1024]; |
311 | int port; | 311 | uint16_t port; |
312 | 312 | ||
313 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | 313 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) |
314 | port = 0; | 314 | port = 0; |
@@ -335,7 +335,7 @@ testMultithreadedPoolPost (void) | |||
335 | { | 335 | { |
336 | MHD_stop_daemon (d); return 32; | 336 | MHD_stop_daemon (d); return 32; |
337 | } | 337 | } |
338 | port = (int) dinfo->port; | 338 | port = dinfo->port; |
339 | } | 339 | } |
340 | for (i = 0; i < LOOPCOUNT; i++) | 340 | for (i = 0; i < LOOPCOUNT; i++) |
341 | { | 341 | { |
@@ -346,8 +346,8 @@ testMultithreadedPoolPost (void) | |||
346 | buf[0] = '\0'; | 346 | buf[0] = '\0'; |
347 | snprintf (url, | 347 | snprintf (url, |
348 | sizeof (url), | 348 | sizeof (url), |
349 | "http://127.0.0.1:%d/hw%d", | 349 | "http://127.0.0.1:%u/hw%d", |
350 | port, | 350 | (unsigned int) port, |
351 | i); | 351 | i); |
352 | curl_easy_setopt (c, CURLOPT_URL, url); | 352 | curl_easy_setopt (c, CURLOPT_URL, url); |
353 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 353 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
@@ -389,7 +389,7 @@ testMultithreadedPoolPost (void) | |||
389 | } | 389 | } |
390 | 390 | ||
391 | 391 | ||
392 | static int | 392 | static unsigned int |
393 | testExternalPost (void) | 393 | testExternalPost (void) |
394 | { | 394 | { |
395 | struct MHD_Daemon *d; | 395 | struct MHD_Daemon *d; |
@@ -415,7 +415,7 @@ testExternalPost (void) | |||
415 | uint64_t timeout64; | 415 | uint64_t timeout64; |
416 | long ctimeout; | 416 | long ctimeout; |
417 | char url[1024]; | 417 | char url[1024]; |
418 | int port; | 418 | uint16_t port; |
419 | 419 | ||
420 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | 420 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) |
421 | port = 0; | 421 | port = 0; |
@@ -442,7 +442,7 @@ testExternalPost (void) | |||
442 | { | 442 | { |
443 | MHD_stop_daemon (d); return 32; | 443 | MHD_stop_daemon (d); return 32; |
444 | } | 444 | } |
445 | port = (int) dinfo->port; | 445 | port = dinfo->port; |
446 | } | 446 | } |
447 | multi = curl_multi_init (); | 447 | multi = curl_multi_init (); |
448 | if (multi == NULL) | 448 | if (multi == NULL) |
@@ -459,8 +459,8 @@ testExternalPost (void) | |||
459 | buf[0] = '\0'; | 459 | buf[0] = '\0'; |
460 | snprintf (url, | 460 | snprintf (url, |
461 | sizeof (url), | 461 | sizeof (url), |
462 | "http://127.0.0.1:%d/hw%d", | 462 | "http://127.0.0.1:%u/hw%d", |
463 | port, | 463 | (unsigned int) port, |
464 | i); | 464 | i); |
465 | curl_easy_setopt (c, CURLOPT_URL, url); | 465 | curl_easy_setopt (c, CURLOPT_URL, url); |
466 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 466 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
@@ -644,21 +644,24 @@ main (int argc, char *const *argv) | |||
644 | oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : | 644 | oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : |
645 | "%s: Sequential POSTs (http/1.0) %f/s\n", | 645 | "%s: Sequential POSTs (http/1.0) %f/s\n", |
646 | "internal select", | 646 | "internal select", |
647 | (double) 1000 * LOOPCOUNT / (now () - start_time + 1.0)); | 647 | (double) 1000 * LOOPCOUNT |
648 | / ((double) (now () - start_time) + 1.0)); | ||
648 | start_time = now (); | 649 | start_time = now (); |
649 | errorCount += testMultithreadedPost (); | 650 | errorCount += testMultithreadedPost (); |
650 | fprintf (stderr, | 651 | fprintf (stderr, |
651 | oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : | 652 | oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : |
652 | "%s: Sequential POSTs (http/1.0) %f/s\n", | 653 | "%s: Sequential POSTs (http/1.0) %f/s\n", |
653 | "multithreaded post", | 654 | "multithreaded post", |
654 | (double) 1000 * LOOPCOUNT / (now () - start_time + 1.0)); | 655 | (double) 1000 * LOOPCOUNT |
656 | / ((double) (now () - start_time) + 1.0)); | ||
655 | start_time = now (); | 657 | start_time = now (); |
656 | errorCount += testMultithreadedPoolPost (); | 658 | errorCount += testMultithreadedPoolPost (); |
657 | fprintf (stderr, | 659 | fprintf (stderr, |
658 | oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : | 660 | oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : |
659 | "%s: Sequential POSTs (http/1.0) %f/s\n", | 661 | "%s: Sequential POSTs (http/1.0) %f/s\n", |
660 | "thread with pool", | 662 | "thread with pool", |
661 | (double) 1000 * LOOPCOUNT / (now () - start_time + 1.0)); | 663 | (double) 1000 * LOOPCOUNT |
664 | / ((double) (now () - start_time) + 1.0)); | ||
662 | } | 665 | } |
663 | start_time = now (); | 666 | start_time = now (); |
664 | errorCount += testExternalPost (); | 667 | errorCount += testExternalPost (); |
@@ -666,7 +669,8 @@ main (int argc, char *const *argv) | |||
666 | oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : | 669 | oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : |
667 | "%s: Sequential POSTs (http/1.0) %f/s\n", | 670 | "%s: Sequential POSTs (http/1.0) %f/s\n", |
668 | "external select", | 671 | "external select", |
669 | (double) 1000 * LOOPCOUNT / (now () - start_time + 1.0)); | 672 | (double) 1000 * LOOPCOUNT |
673 | / ((double) (now () - start_time) + 1.0)); | ||
670 | if (errorCount != 0) | 674 | if (errorCount != 0) |
671 | fprintf (stderr, "Error (code: %u)\n", errorCount); | 675 | fprintf (stderr, "Error (code: %u)\n", errorCount); |
672 | curl_global_cleanup (); | 676 | curl_global_cleanup (); |