test_post_loop.c (19420B)
1 /* 2 This file is part of libmicrohttpd 3 Copyright (C) 2007 Christian Grothoff 4 Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) 5 6 libmicrohttpd is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published 8 by the Free Software Foundation; either version 2, or (at your 9 option) any later version. 10 11 libmicrohttpd is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with libmicrohttpd; see the file COPYING. If not, write to the 18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 Boston, MA 02110-1301, USA. 20 */ 21 22 /** 23 * @file daemontest_post_loop.c 24 * @brief Testcase for libmicrohttpd POST operations using URL-encoding 25 * @author Christian Grothoff (inspired by bug report #1296) 26 * @author Karlson2k (Evgeny Grin) 27 */ 28 29 #include "MHD_config.h" 30 #include "platform.h" 31 #include <curl/curl.h> 32 #include <microhttpd.h> 33 #include <stdlib.h> 34 #include <string.h> 35 #include <time.h> 36 #include <errno.h> 37 #include "mhd_has_in_name.h" 38 39 /* Turn any MHD_PANIC() or failing mhd_assert() reached from this 40 test into a marked, classifiable test error (TESTING.md, P5). */ 41 #include "mhd_panic_tripwire.h" 42 43 #ifndef WINDOWS 44 #include <unistd.h> 45 #endif 46 47 #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 48 #undef MHD_CPU_COUNT 49 #endif 50 #if ! defined(MHD_CPU_COUNT) 51 #define MHD_CPU_COUNT 2 52 #endif 53 54 #define POST_DATA \ 55 "<?xml version='1.0' ?>\n<xml>\n<data-id>1</data-id>\n</xml>\n" 56 57 #ifndef __APPLE__ 58 #define LOOPCOUNT 1000 59 #else /* __APPLE__ */ 60 /* FIXME: macOS may fail in this test with "unable to connect". Investigate deeper? */ 61 #define LOOPCOUNT 200 62 #endif /* __APPLE__ */ 63 64 static int oneone; 65 66 struct CBC 67 { 68 char *buf; 69 size_t pos; 70 size_t size; 71 }; 72 73 static size_t 74 copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) 75 { 76 struct CBC *cbc = ctx; 77 78 if (cbc->pos + size * nmemb > cbc->size) 79 return 0; /* overflow */ 80 memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); 81 cbc->pos += size * nmemb; 82 return size * nmemb; 83 } 84 85 86 static enum MHD_Result 87 ahc_echo (void *cls, 88 struct MHD_Connection *connection, 89 const char *url, 90 const char *method, 91 const char *version, 92 const char *upload_data, size_t *upload_data_size, 93 void **req_cls) 94 { 95 static int marker; 96 struct MHD_Response *response; 97 enum MHD_Result ret; 98 (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ 99 (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ 100 101 if (0 != strcmp ("POST", method)) 102 { 103 printf ("METHOD: %s\n", method); 104 return MHD_NO; /* unexpected method */ 105 } 106 if ((*req_cls != NULL) && (0 == *upload_data_size)) 107 { 108 if (*req_cls != &marker) 109 abort (); 110 response = MHD_create_response_from_buffer_static (2, 111 "OK"); 112 ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 113 MHD_destroy_response (response); 114 *req_cls = NULL; 115 return ret; 116 } 117 if (strlen (POST_DATA) != *upload_data_size) 118 return MHD_YES; 119 *upload_data_size = 0; 120 *req_cls = ▮ 121 return MHD_YES; 122 } 123 124 125 static unsigned int 126 testInternalPost (void) 127 { 128 struct MHD_Daemon *d; 129 CURL *c; 130 char buf[2048]; 131 struct CBC cbc; 132 CURLcode errornum; 133 int i; 134 char url[1024]; 135 uint16_t port; 136 137 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 138 port = 0; 139 else 140 { 141 port = 1350; 142 if (oneone) 143 port += 10; 144 } 145 146 cbc.buf = buf; 147 cbc.size = 2048; 148 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 149 port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); 150 if (d == NULL) 151 return 1; 152 if (0 == port) 153 { 154 const union MHD_DaemonInfo *dinfo; 155 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); 156 if ((NULL == dinfo) || (0 == dinfo->port) ) 157 { 158 MHD_stop_daemon (d); return 32; 159 } 160 port = dinfo->port; 161 } 162 for (i = 0; i < LOOPCOUNT; i++) 163 { 164 if (99 == i % 100) 165 fprintf (stderr, "."); 166 c = curl_easy_init (); 167 cbc.pos = 0; 168 buf[0] = '\0'; 169 snprintf (url, 170 sizeof (url), 171 "http://127.0.0.1:%u/hw%d", 172 (unsigned int) port, 173 i); 174 curl_easy_setopt (c, CURLOPT_URL, url); 175 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); 176 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 177 curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); 178 curl_easy_setopt (c, CURLOPT_POSTFIELDSIZE, strlen (POST_DATA)); 179 curl_easy_setopt (c, CURLOPT_POST, 1L); 180 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); 181 curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); 182 if (oneone) 183 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 184 else 185 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); 186 curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); 187 /* NOTE: use of CONNECTTIMEOUT without also 188 * setting NOSIGNAL results in really weird 189 * crashes on my system! */ 190 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); 191 curl_easy_setopt (c, CURLOPT_PROXY, ""); 192 if (CURLE_OK != (errornum = curl_easy_perform (c))) 193 { 194 fprintf (stderr, 195 "curl_easy_perform failed: `%s'\n", 196 curl_easy_strerror (errornum)); 197 curl_easy_cleanup (c); 198 MHD_stop_daemon (d); 199 return 2; 200 } 201 curl_easy_cleanup (c); 202 if ((buf[0] != 'O') || (buf[1] != 'K')) 203 { 204 MHD_stop_daemon (d); 205 return 4; 206 } 207 } 208 MHD_stop_daemon (d); 209 if (LOOPCOUNT >= 99) 210 fprintf (stderr, "\n"); 211 return 0; 212 } 213 214 215 static unsigned int 216 testMultithreadedPost (void) 217 { 218 struct MHD_Daemon *d; 219 CURL *c; 220 char buf[2048]; 221 struct CBC cbc; 222 CURLcode errornum; 223 int i; 224 char url[1024]; 225 uint16_t port; 226 227 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 228 port = 0; 229 else 230 { 231 port = 1351; 232 if (oneone) 233 port += 10; 234 } 235 236 cbc.buf = buf; 237 cbc.size = 2048; 238 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION 239 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 240 port, NULL, NULL, 241 &ahc_echo, NULL, 242 MHD_OPTION_END); 243 if (d == NULL) 244 return 16; 245 if (0 == port) 246 { 247 const union MHD_DaemonInfo *dinfo; 248 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); 249 if ((NULL == dinfo) || (0 == dinfo->port) ) 250 { 251 MHD_stop_daemon (d); return 32; 252 } 253 port = dinfo->port; 254 } 255 for (i = 0; i < LOOPCOUNT; i++) 256 { 257 if (99 == i % 100) 258 fprintf (stderr, "."); 259 c = curl_easy_init (); 260 cbc.pos = 0; 261 buf[0] = '\0'; 262 snprintf (url, 263 sizeof (url), 264 "http://127.0.0.1:%u/hw%d", 265 (unsigned int) port, 266 i); 267 curl_easy_setopt (c, CURLOPT_URL, url); 268 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); 269 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 270 curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); 271 curl_easy_setopt (c, CURLOPT_POSTFIELDSIZE, strlen (POST_DATA)); 272 curl_easy_setopt (c, CURLOPT_POST, 1L); 273 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); 274 curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); 275 if (oneone) 276 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 277 else 278 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); 279 curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); 280 /* NOTE: use of CONNECTTIMEOUT without also 281 * setting NOSIGNAL results in really weird 282 * crashes on my system! */ 283 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); 284 curl_easy_setopt (c, CURLOPT_PROXY, ""); 285 if (CURLE_OK != (errornum = curl_easy_perform (c))) 286 { 287 fprintf (stderr, 288 "curl_easy_perform failed: `%s'\n", 289 curl_easy_strerror (errornum)); 290 curl_easy_cleanup (c); 291 MHD_stop_daemon (d); 292 return 32; 293 } 294 curl_easy_cleanup (c); 295 if ((buf[0] != 'O') || (buf[1] != 'K')) 296 { 297 MHD_stop_daemon (d); 298 return 64; 299 } 300 } 301 MHD_stop_daemon (d); 302 if (LOOPCOUNT >= 99) 303 fprintf (stderr, "\n"); 304 return 0; 305 } 306 307 308 static unsigned int 309 testMultithreadedPoolPost (void) 310 { 311 struct MHD_Daemon *d; 312 CURL *c; 313 char buf[2048]; 314 struct CBC cbc; 315 CURLcode errornum; 316 int i; 317 char url[1024]; 318 uint16_t port; 319 320 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 321 port = 0; 322 else 323 { 324 port = 1352; 325 if (oneone) 326 port += 10; 327 } 328 329 cbc.buf = buf; 330 cbc.size = 2048; 331 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 332 port, NULL, NULL, &ahc_echo, NULL, 333 MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, 334 MHD_OPTION_END); 335 if (d == NULL) 336 return 16; 337 if (0 == port) 338 { 339 const union MHD_DaemonInfo *dinfo; 340 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); 341 if ((NULL == dinfo) || (0 == dinfo->port) ) 342 { 343 MHD_stop_daemon (d); return 32; 344 } 345 port = dinfo->port; 346 } 347 for (i = 0; i < LOOPCOUNT; i++) 348 { 349 if (99 == i % 100) 350 fprintf (stderr, "."); 351 c = curl_easy_init (); 352 cbc.pos = 0; 353 buf[0] = '\0'; 354 snprintf (url, 355 sizeof (url), 356 "http://127.0.0.1:%u/hw%d", 357 (unsigned int) port, 358 i); 359 curl_easy_setopt (c, CURLOPT_URL, url); 360 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); 361 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 362 curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); 363 curl_easy_setopt (c, CURLOPT_POSTFIELDSIZE, strlen (POST_DATA)); 364 curl_easy_setopt (c, CURLOPT_POST, 1L); 365 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); 366 curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); 367 if (oneone) 368 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 369 else 370 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); 371 curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); 372 /* NOTE: use of CONNECTTIMEOUT without also 373 * setting NOSIGNAL results in really weird 374 * crashes on my system! */ 375 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); 376 curl_easy_setopt (c, CURLOPT_PROXY, ""); 377 if (CURLE_OK != (errornum = curl_easy_perform (c))) 378 { 379 fprintf (stderr, 380 "curl_easy_perform failed: `%s'\n", 381 curl_easy_strerror (errornum)); 382 curl_easy_cleanup (c); 383 MHD_stop_daemon (d); 384 return 32; 385 } 386 curl_easy_cleanup (c); 387 if ((buf[0] != 'O') || (buf[1] != 'K')) 388 { 389 MHD_stop_daemon (d); 390 return 64; 391 } 392 } 393 MHD_stop_daemon (d); 394 if (LOOPCOUNT >= 99) 395 fprintf (stderr, "\n"); 396 return 0; 397 } 398 399 400 static unsigned int 401 testExternalPost (void) 402 { 403 struct MHD_Daemon *d; 404 CURL *c; 405 char buf[2048]; 406 struct CBC cbc; 407 CURLM *multi; 408 CURLMcode mret; 409 fd_set rs; 410 fd_set ws; 411 fd_set es; 412 MHD_socket maxsock; 413 #ifdef MHD_WINSOCK_SOCKETS 414 int maxposixs; /* Max socket number unused on W32 */ 415 #else /* MHD_POSIX_SOCKETS */ 416 #define maxposixs maxsock 417 #endif /* MHD_POSIX_SOCKETS */ 418 int running; 419 struct CURLMsg *msg; 420 time_t start; 421 struct timeval tv; 422 int i; 423 uint64_t timeout64; 424 long ctimeout; 425 char url[1024]; 426 uint16_t port; 427 428 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 429 port = 0; 430 else 431 { 432 port = 1353; 433 if (oneone) 434 port += 10; 435 } 436 437 multi = NULL; 438 cbc.buf = buf; 439 cbc.size = 2048; 440 cbc.pos = 0; 441 d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, 442 port, NULL, NULL, &ahc_echo, NULL, 443 MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, 444 MHD_OPTION_END); 445 if (d == NULL) 446 return 256; 447 if (0 == port) 448 { 449 const union MHD_DaemonInfo *dinfo; 450 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); 451 if ((NULL == dinfo) || (0 == dinfo->port) ) 452 { 453 MHD_stop_daemon (d); return 32; 454 } 455 port = dinfo->port; 456 } 457 multi = curl_multi_init (); 458 if (multi == NULL) 459 { 460 MHD_stop_daemon (d); 461 return 512; 462 } 463 for (i = 0; i < LOOPCOUNT; i++) 464 { 465 if (99 == i % 100) 466 fprintf (stderr, "."); 467 c = curl_easy_init (); 468 cbc.pos = 0; 469 buf[0] = '\0'; 470 snprintf (url, 471 sizeof (url), 472 "http://127.0.0.1:%u/hw%d", 473 (unsigned int) port, 474 i); 475 curl_easy_setopt (c, CURLOPT_URL, url); 476 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); 477 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 478 curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); 479 curl_easy_setopt (c, CURLOPT_POSTFIELDSIZE, strlen (POST_DATA)); 480 curl_easy_setopt (c, CURLOPT_POST, 1L); 481 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); 482 curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); 483 if (oneone) 484 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 485 else 486 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); 487 curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); 488 /* NOTE: use of CONNECTTIMEOUT without also 489 * setting NOSIGNAL results in really weird 490 * crashes on my system! */ 491 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); 492 curl_easy_setopt (c, CURLOPT_PROXY, ""); 493 mret = curl_multi_add_handle (multi, c); 494 if (mret != CURLM_OK) 495 { 496 curl_multi_cleanup (multi); 497 curl_easy_cleanup (c); 498 MHD_stop_daemon (d); 499 return 1024; 500 } 501 start = time (NULL); 502 while ((time (NULL) - start < 5) && (multi != NULL)) 503 { 504 maxsock = MHD_INVALID_SOCKET; 505 maxposixs = -1; 506 FD_ZERO (&rs); 507 FD_ZERO (&ws); 508 FD_ZERO (&es); 509 while (CURLM_CALL_MULTI_PERFORM == 510 curl_multi_perform (multi, &running)) 511 ; 512 mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); 513 if (mret != CURLM_OK) 514 { 515 curl_multi_remove_handle (multi, c); 516 curl_multi_cleanup (multi); 517 curl_easy_cleanup (c); 518 MHD_stop_daemon (d); 519 return 2048; 520 } 521 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) 522 { 523 curl_multi_remove_handle (multi, c); 524 curl_multi_cleanup (multi); 525 curl_easy_cleanup (c); 526 MHD_stop_daemon (d); 527 return 4096; 528 } 529 if (MHD_NO == MHD_get_timeout64 (d, &timeout64)) 530 timeout64 = 100; /* 100ms == INFTY -- CURL bug... */ 531 if ((CURLM_OK == curl_multi_timeout (multi, &ctimeout)) && 532 (ctimeout >= 0) && ((uint64_t) ctimeout < timeout64)) 533 timeout64 = (uint64_t) ctimeout; 534 if (0 == running) 535 timeout64 = 0; /* terminate quickly... */ 536 #if ! defined(_WIN32) || defined(__CYGWIN__) 537 tv.tv_sec = (time_t) (timeout64 / 1000); 538 #else /* Native W32 */ 539 tv.tv_sec = (long) (timeout64 / 1000); 540 #endif /* Native W32 */ 541 tv.tv_usec = (long) (1000 * (timeout64 % 1000)); 542 if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) 543 { 544 #ifdef MHD_POSIX_SOCKETS 545 if (EINTR != errno) 546 { 547 fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", 548 (int) errno, __LINE__); 549 fflush (stderr); 550 exit (99); 551 } 552 #else 553 if ((WSAEINVAL != WSAGetLastError ()) || 554 (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) 555 { 556 fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", 557 (int) WSAGetLastError (), __LINE__); 558 fflush (stderr); 559 exit (99); 560 } 561 Sleep (1); 562 #endif 563 } 564 while (CURLM_CALL_MULTI_PERFORM == 565 curl_multi_perform (multi, &running)) 566 ; 567 if (0 == running) 568 { 569 int pending; 570 int curl_fine = 0; 571 while (NULL != (msg = curl_multi_info_read (multi, &pending))) 572 { 573 if (msg->msg == CURLMSG_DONE) 574 { 575 if (msg->data.result == CURLE_OK) 576 curl_fine = 1; 577 else 578 { 579 fprintf (stderr, 580 "%s failed at %s:%d: `%s'\n", 581 "curl_multi_perform", 582 __FILE__, 583 __LINE__, curl_easy_strerror (msg->data.result)); 584 abort (); 585 } 586 } 587 } 588 if (! curl_fine) 589 { 590 fprintf (stderr, "libcurl haven't returned OK code\n"); 591 abort (); 592 } 593 break; 594 } 595 MHD_run (d); 596 } 597 if (NULL != c) 598 { 599 curl_multi_remove_handle (multi, c); 600 curl_easy_cleanup (c); 601 } 602 if ((buf[0] != 'O') || (buf[1] != 'K')) 603 { 604 curl_multi_cleanup (multi); 605 MHD_stop_daemon (d); 606 return 8192; 607 } 608 } 609 curl_multi_cleanup (multi); 610 MHD_stop_daemon (d); 611 if (LOOPCOUNT >= 99) 612 fprintf (stderr, "\n"); 613 return 0; 614 } 615 616 617 /** 618 * Time this round was started. 619 */ 620 static unsigned long long start_time; 621 622 623 /** 624 * Get the current timestamp 625 * 626 * @return current time in ms 627 */ 628 static unsigned long long 629 now (void) 630 { 631 struct timeval tv; 632 633 gettimeofday (&tv, NULL); 634 return (((unsigned long long) tv.tv_sec * 1000LL) 635 + ((unsigned long long) tv.tv_usec / 1000LL)); 636 } 637 638 639 int 640 main (int argc, char *const *argv) 641 { 642 unsigned int errorCount = 0; 643 (void) argc; /* Unused. Silent compiler warning. */ 644 645 if ((NULL == argv) || (0 == argv[0])) 646 return 99; 647 oneone = has_in_name (argv[0], "11"); 648 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 649 return 2; 650 if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) 651 { 652 start_time = now (); 653 errorCount += testInternalPost (); 654 fprintf (stderr, 655 oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : 656 "%s: Sequential POSTs (http/1.0) %f/s\n", 657 "internal select", 658 (double) 1000 * LOOPCOUNT 659 / ((double) (now () - start_time) + 1.0)); 660 start_time = now (); 661 errorCount += testMultithreadedPost (); 662 fprintf (stderr, 663 oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : 664 "%s: Sequential POSTs (http/1.0) %f/s\n", 665 "multithreaded post", 666 (double) 1000 * LOOPCOUNT 667 / ((double) (now () - start_time) + 1.0)); 668 start_time = now (); 669 errorCount += testMultithreadedPoolPost (); 670 fprintf (stderr, 671 oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : 672 "%s: Sequential POSTs (http/1.0) %f/s\n", 673 "thread with pool", 674 (double) 1000 * LOOPCOUNT 675 / ((double) (now () - start_time) + 1.0)); 676 } 677 start_time = now (); 678 errorCount += testExternalPost (); 679 fprintf (stderr, 680 oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : 681 "%s: Sequential POSTs (http/1.0) %f/s\n", 682 "external select", 683 (double) 1000 * LOOPCOUNT 684 / ((double) (now () - start_time) + 1.0)); 685 if (errorCount != 0) 686 fprintf (stderr, "Error (code: %u)\n", errorCount); 687 curl_global_cleanup (); 688 return (0 == errorCount) ? 0 : 1; /* 0 == pass */ 689 }