diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-09-23 14:30:36 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-09-23 14:30:36 +0000 |
commit | a0060ee639310e960c6a2ab4b145708f544093af (patch) | |
tree | aa618dc2d9174c07ae97effbfeda58b01d85b52b | |
parent | e73f48f6baa5bc1609cddb7b6ba00257ddd63951 (diff) | |
download | libmicrohttpd-a0060ee639310e960c6a2ab4b145708f544093af.tar.gz libmicrohttpd-a0060ee639310e960c6a2ab4b145708f544093af.zip |
-check select() return value
-rw-r--r-- | src/testcurl/test_post.c | 55 | ||||
-rw-r--r-- | src/testcurl/test_process_headers.c | 6 | ||||
-rw-r--r-- | src/testcurl/test_put.c | 6 |
3 files changed, 39 insertions, 28 deletions
diff --git a/src/testcurl/test_post.c b/src/testcurl/test_post.c index 7872e652..291c5ce3 100644 --- a/src/testcurl/test_post.c +++ b/src/testcurl/test_post.c | |||
@@ -71,7 +71,7 @@ completed_cb (void *cls, | |||
71 | struct MHD_PostProcessor *pp = *con_cls; | 71 | struct MHD_PostProcessor *pp = *con_cls; |
72 | 72 | ||
73 | if (NULL != pp) | 73 | if (NULL != pp) |
74 | MHD_destroy_post_processor (pp); | 74 | MHD_destroy_post_processor (pp); |
75 | *con_cls = NULL; | 75 | *con_cls = NULL; |
76 | } | 76 | } |
77 | 77 | ||
@@ -171,8 +171,8 @@ testInternalPost () | |||
171 | cbc.size = 2048; | 171 | cbc.size = 2048; |
172 | cbc.pos = 0; | 172 | cbc.pos = 0; |
173 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 173 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, |
174 | 1080, NULL, NULL, &ahc_echo, NULL, | 174 | 1080, NULL, NULL, &ahc_echo, NULL, |
175 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, | 175 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, |
176 | MHD_OPTION_END); | 176 | MHD_OPTION_END); |
177 | if (d == NULL) | 177 | if (d == NULL) |
178 | return 1; | 178 | return 1; |
@@ -225,8 +225,8 @@ testMultithreadedPost () | |||
225 | cbc.size = 2048; | 225 | cbc.size = 2048; |
226 | cbc.pos = 0; | 226 | cbc.pos = 0; |
227 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, | 227 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, |
228 | 1081, NULL, NULL, &ahc_echo, NULL, | 228 | 1081, NULL, NULL, &ahc_echo, NULL, |
229 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, | 229 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, |
230 | MHD_OPTION_END); | 230 | MHD_OPTION_END); |
231 | if (d == NULL) | 231 | if (d == NULL) |
232 | return 16; | 232 | return 16; |
@@ -281,7 +281,7 @@ testMultithreadedPoolPost () | |||
281 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 281 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, |
282 | 1081, NULL, NULL, &ahc_echo, NULL, | 282 | 1081, NULL, NULL, &ahc_echo, NULL, |
283 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, | 283 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, |
284 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, | 284 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, |
285 | MHD_OPTION_END); | 285 | MHD_OPTION_END); |
286 | if (d == NULL) | 286 | if (d == NULL) |
287 | return 16; | 287 | return 16; |
@@ -349,8 +349,8 @@ testExternalPost () | |||
349 | cbc.size = 2048; | 349 | cbc.size = 2048; |
350 | cbc.pos = 0; | 350 | cbc.pos = 0; |
351 | d = MHD_start_daemon (MHD_USE_DEBUG, | 351 | d = MHD_start_daemon (MHD_USE_DEBUG, |
352 | 1082, NULL, NULL, &ahc_echo, NULL, | 352 | 1082, NULL, NULL, &ahc_echo, NULL, |
353 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, | 353 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, |
354 | MHD_OPTION_END); | 354 | MHD_OPTION_END); |
355 | if (d == NULL) | 355 | if (d == NULL) |
356 | return 256; | 356 | return 256; |
@@ -417,7 +417,11 @@ testExternalPost () | |||
417 | } | 417 | } |
418 | tv.tv_sec = 0; | 418 | tv.tv_sec = 0; |
419 | tv.tv_usec = 1000; | 419 | tv.tv_usec = 1000; |
420 | select (maxposixs + 1, &rs, &ws, &es, &tv); | 420 | if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) |
421 | { | ||
422 | if (EINTR != errno) | ||
423 | abort (); | ||
424 | } | ||
421 | curl_multi_perform (multi, &running); | 425 | curl_multi_perform (multi, &running); |
422 | if (running == 0) | 426 | if (running == 0) |
423 | { | 427 | { |
@@ -437,8 +441,7 @@ testExternalPost () | |||
437 | c = NULL; | 441 | c = NULL; |
438 | multi = NULL; | 442 | multi = NULL; |
439 | } | 443 | } |
440 | } | 444 | } MHD_run (d); |
441 | MHD_run (d); | ||
442 | } | 445 | } |
443 | if (multi != NULL) | 446 | if (multi != NULL) |
444 | { | 447 | { |
@@ -471,14 +474,14 @@ ahc_cancel (void *cls, | |||
471 | { | 474 | { |
472 | fprintf (stderr, | 475 | fprintf (stderr, |
473 | "Unexpected method `%s'\n", method); | 476 | "Unexpected method `%s'\n", method); |
474 | return MHD_NO; | 477 | return MHD_NO; |
475 | } | 478 | } |
476 | 479 | ||
477 | if (*unused == NULL) | 480 | if (*unused == NULL) |
478 | { | 481 | { |
479 | *unused = "wibble"; | 482 | *unused = "wibble"; |
480 | /* We don't want the body. Send a 500. */ | 483 | /* We don't want the body. Send a 500. */ |
481 | response = MHD_create_response_from_buffer (0, NULL, | 484 | response = MHD_create_response_from_buffer (0, NULL, |
482 | MHD_RESPMEM_PERSISTENT); | 485 | MHD_RESPMEM_PERSISTENT); |
483 | ret = MHD_queue_response(connection, 500, response); | 486 | ret = MHD_queue_response(connection, 500, response); |
484 | if (ret != MHD_YES) | 487 | if (ret != MHD_YES) |
@@ -488,7 +491,7 @@ ahc_cancel (void *cls, | |||
488 | } | 491 | } |
489 | else | 492 | else |
490 | { | 493 | { |
491 | fprintf(stderr, | 494 | fprintf(stderr, |
492 | "In ahc_cancel again. This should not happen.\n"); | 495 | "In ahc_cancel again. This should not happen.\n"); |
493 | return MHD_NO; | 496 | return MHD_NO; |
494 | } | 497 | } |
@@ -502,24 +505,24 @@ struct CRBC | |||
502 | }; | 505 | }; |
503 | 506 | ||
504 | 507 | ||
505 | static size_t | 508 | static size_t |
506 | readBuffer(void *p, size_t size, size_t nmemb, void *opaque) | 509 | readBuffer(void *p, size_t size, size_t nmemb, void *opaque) |
507 | { | 510 | { |
508 | struct CRBC *data = opaque; | 511 | struct CRBC *data = opaque; |
509 | size_t required = size * nmemb; | 512 | size_t required = size * nmemb; |
510 | size_t left = data->size - data->pos; | 513 | size_t left = data->size - data->pos; |
511 | 514 | ||
512 | if (required > left) | 515 | if (required > left) |
513 | required = left; | 516 | required = left; |
514 | 517 | ||
515 | memcpy(p, data->buffer + data->pos, required); | 518 | memcpy(p, data->buffer + data->pos, required); |
516 | data->pos += required; | 519 | data->pos += required; |
517 | 520 | ||
518 | return required/size; | 521 | return required/size; |
519 | } | 522 | } |
520 | 523 | ||
521 | 524 | ||
522 | static size_t | 525 | static size_t |
523 | slowReadBuffer(void *p, size_t size, size_t nmemb, void *opaque) | 526 | slowReadBuffer(void *p, size_t size, size_t nmemb, void *opaque) |
524 | { | 527 | { |
525 | sleep(1); | 528 | sleep(1); |
@@ -557,7 +560,7 @@ testMultithreadedPostCancelPart(int flags) | |||
557 | cbc.size = 2048; | 560 | cbc.size = 2048; |
558 | cbc.pos = 0; | 561 | cbc.pos = 0; |
559 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, | 562 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, |
560 | 1081, NULL, NULL, &ahc_cancel, NULL, | 563 | 1081, NULL, NULL, &ahc_cancel, NULL, |
561 | MHD_OPTION_END); | 564 | MHD_OPTION_END); |
562 | if (d == NULL) | 565 | if (d == NULL) |
563 | return 32768; | 566 | return 32768; |
@@ -565,7 +568,7 @@ testMultithreadedPostCancelPart(int flags) | |||
565 | crbc.buffer = "Test content"; | 568 | crbc.buffer = "Test content"; |
566 | crbc.size = strlen(crbc.buffer); | 569 | crbc.size = strlen(crbc.buffer); |
567 | crbc.pos = 0; | 570 | crbc.pos = 0; |
568 | 571 | ||
569 | c = curl_easy_init (); | 572 | c = curl_easy_init (); |
570 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); | 573 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1081/hello_world"); |
571 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 574 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
@@ -594,7 +597,7 @@ testMultithreadedPostCancelPart(int flags) | |||
594 | if (flags & FLAG_EXPECT_CONTINUE) | 597 | if (flags & FLAG_EXPECT_CONTINUE) |
595 | headers = curl_slist_append(headers, "Expect: 100-Continue"); | 598 | headers = curl_slist_append(headers, "Expect: 100-Continue"); |
596 | curl_easy_setopt(c, CURLOPT_HTTPHEADER, headers); | 599 | curl_easy_setopt(c, CURLOPT_HTTPHEADER, headers); |
597 | 600 | ||
598 | if (CURLE_HTTP_RETURNED_ERROR != (errornum = curl_easy_perform (c))) | 601 | if (CURLE_HTTP_RETURNED_ERROR != (errornum = curl_easy_perform (c))) |
599 | { | 602 | { |
600 | #ifdef _WIN32 | 603 | #ifdef _WIN32 |
@@ -620,19 +623,19 @@ testMultithreadedPostCancelPart(int flags) | |||
620 | curl_slist_free_all(headers); | 623 | curl_slist_free_all(headers); |
621 | return result; | 624 | return result; |
622 | } | 625 | } |
623 | 626 | ||
624 | if (CURLE_OK != (cc = curl_easy_getinfo(c, CURLINFO_RESPONSE_CODE, &response_code))) | 627 | if (CURLE_OK != (cc = curl_easy_getinfo(c, CURLINFO_RESPONSE_CODE, &response_code))) |
625 | { | 628 | { |
626 | fprintf(stderr, "curl_easy_getinfo failed: '%s'\n", curl_easy_strerror(errornum)); | 629 | fprintf(stderr, "curl_easy_getinfo failed: '%s'\n", curl_easy_strerror(errornum)); |
627 | result = 65536; | 630 | result = 65536; |
628 | } | 631 | } |
629 | 632 | ||
630 | if (!result && (response_code != 500)) | 633 | if (!result && (response_code != 500)) |
631 | { | 634 | { |
632 | fprintf(stderr, "Unexpected response code: %ld\n", response_code); | 635 | fprintf(stderr, "Unexpected response code: %ld\n", response_code); |
633 | result = 131072; | 636 | result = 131072; |
634 | } | 637 | } |
635 | 638 | ||
636 | if (!result && (cbc.pos != 0)) | 639 | if (!result && (cbc.pos != 0)) |
637 | result = 262144; | 640 | result = 262144; |
638 | 641 | ||
@@ -649,7 +652,7 @@ testMultithreadedPostCancel() | |||
649 | int result = 0; | 652 | int result = 0; |
650 | int flags; | 653 | int flags; |
651 | for(flags = 0; flags < FLAG_COUNT; ++flags) | 654 | for(flags = 0; flags < FLAG_COUNT; ++flags) |
652 | result |= testMultithreadedPostCancelPart(flags); | 655 | result |= testMultithreadedPostCancelPart(flags); |
653 | return result; | 656 | return result; |
654 | } | 657 | } |
655 | 658 | ||
diff --git a/src/testcurl/test_process_headers.c b/src/testcurl/test_process_headers.c index e13851fa..43f3a17e 100644 --- a/src/testcurl/test_process_headers.c +++ b/src/testcurl/test_process_headers.c | |||
@@ -384,7 +384,11 @@ testExternalGet () | |||
384 | } | 384 | } |
385 | tv.tv_sec = 0; | 385 | tv.tv_sec = 0; |
386 | tv.tv_usec = 1000; | 386 | tv.tv_usec = 1000; |
387 | select (maxposixs + 1, &rs, &ws, &es, &tv); | 387 | if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) |
388 | { | ||
389 | if (EINTR != errno) | ||
390 | abort (); | ||
391 | } | ||
388 | curl_multi_perform (multi, &running); | 392 | curl_multi_perform (multi, &running); |
389 | if (running == 0) | 393 | if (running == 0) |
390 | { | 394 | { |
diff --git a/src/testcurl/test_put.c b/src/testcurl/test_put.c index 1032278f..d32c0af1 100644 --- a/src/testcurl/test_put.c +++ b/src/testcurl/test_put.c | |||
@@ -387,7 +387,11 @@ testExternalPut () | |||
387 | } | 387 | } |
388 | tv.tv_sec = 0; | 388 | tv.tv_sec = 0; |
389 | tv.tv_usec = 1000; | 389 | tv.tv_usec = 1000; |
390 | select (maxposixs + 1, &rs, &ws, &es, &tv); | 390 | if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) |
391 | { | ||
392 | if (EINTR != errno) | ||
393 | abort (); | ||
394 | } | ||
391 | curl_multi_perform (multi, &running); | 395 | curl_multi_perform (multi, &running); |
392 | if (running == 0) | 396 | if (running == 0) |
393 | { | 397 | { |