| 553 | |
| 554 | |
| 555 | int |
| 556 | iperf_run_server(struct iperf_test *test) |
| 557 | { |
| 558 | int result, s; |
| 559 | int send_streams_accepted, rec_streams_accepted; |
| 560 | int streams_to_send = 0, streams_to_rec = 0; |
| 561 | #if defined(HAVE_TCP_CONGESTION) |
| 562 | int saved_errno; |
| 563 | #endif /* HAVE_TCP_CONGESTION */ |
| 564 | fd_set read_set, write_set; |
| 565 | struct iperf_stream *sp; |
| 566 | struct iperf_time now; |
| 567 | struct iperf_time last_receive_time; |
| 568 | struct iperf_time diff_time; |
| 569 | struct timeval* timeout; |
| 570 | struct timeval used_timeout; |
| 571 | iperf_size_t last_receive_blocks; |
| 572 | int flag; |
| 573 | int64_t t_usecs; |
| 574 | int64_t timeout_us; |
| 575 | int64_t rcv_timeout_us; |
| 576 | int32_t err; |
| 577 | |
| 578 | if (test->logfile) { |
| 579 | if (iperf_open_logfile(test) < 0) |
| 580 | return -2; |
| 581 | } |
| 582 | |
| 583 | if (test->affinity != -1) { |
| 584 | if (iperf_setaffinity(test, test->affinity) != 0) { |
| 585 | cleanup_server(test); |
| 586 | return -2; |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | if (test->json_output) { |
| 591 | if (iperf_json_start(test) < 0) { |
| 592 | cleanup_server(test); |
| 593 | return -2; |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | if (test->json_output) { |
| 598 | cJSON_AddItemToObject(test->json_start, "version", cJSON_CreateString(version)); |
| 599 | cJSON_AddItemToObject(test->json_start, "system_info", cJSON_CreateString(get_system_info())); |
| 600 | } else if (test->verbose) { |
| 601 | iperf_printf(test, "%s\n", version); |
| 602 | iperf_printf(test, "%s", ""); |
| 603 | iperf_printf(test, "%s\n", get_system_info()); |
| 604 | iflush(test); |
| 605 | } |
| 606 | |
| 607 | // Open socket and listen |
| 608 | if (iperf_server_listen(test) < 0) { |
| 609 | cleanup_server(test); |
| 610 | return -2; |
| 611 | } |
| 612 |
no test coverage detected
searching dependent graphs…