| 572 | } |
| 573 | |
| 574 | static int test(int backlog, unsigned int max_sends, int *to_eagain, |
| 575 | int send_bundle, int recv_bundle) |
| 576 | { |
| 577 | pthread_t recv_thread; |
| 578 | struct recv_data rd; |
| 579 | int ret; |
| 580 | void *retval; |
| 581 | |
| 582 | /* backlog not reliable on UDP, skip it */ |
| 583 | if ((backlog || max_sends) && !use_tcp) |
| 584 | return T_EXIT_PASS; |
| 585 | |
| 586 | memset(&rd, 0, sizeof(rd)); |
| 587 | pthread_barrier_init(&rd.connect, NULL, 2); |
| 588 | pthread_barrier_init(&rd.startup, NULL, 2); |
| 589 | pthread_barrier_init(&rd.barrier, NULL, 2); |
| 590 | pthread_barrier_init(&rd.finish, NULL, 2); |
| 591 | rd.max_sends = max_sends; |
| 592 | if (to_eagain) |
| 593 | *to_eagain = 0; |
| 594 | |
| 595 | rd.send_bundle = send_bundle; |
| 596 | rd.recv_bundle = recv_bundle; |
| 597 | |
| 598 | ret = pthread_create(&recv_thread, NULL, recv_fn, &rd); |
| 599 | if (ret) { |
| 600 | fprintf(stderr, "Thread create failed: %d\n", ret); |
| 601 | return 1; |
| 602 | } |
| 603 | |
| 604 | ret = do_send(&rd); |
| 605 | if (no_send_mshot) { |
| 606 | fprintf(stderr, "no_send_mshot, aborting (ignore other errors)\n"); |
| 607 | rd.abort = 1; |
| 608 | pthread_join(recv_thread, &retval); |
| 609 | return 0; |
| 610 | } |
| 611 | |
| 612 | if (ret) |
| 613 | return ret; |
| 614 | |
| 615 | pthread_join(recv_thread, &retval); |
| 616 | if (to_eagain) |
| 617 | *to_eagain = rd.to_eagain; |
| 618 | return (intptr_t)retval; |
| 619 | } |
| 620 | |
| 621 | static int run_tests(int is_udp) |
| 622 | { |