--- embedaddon/iperf/src/main.c 2021/03/17 00:36:46 1.1.1.2 +++ embedaddon/iperf/src/main.c 2023/09/27 11:14:54 1.1.1.3 @@ -1,5 +1,5 @@ /* - * iperf, Copyright (c) 2014, 2015, 2017, 2019, The Regents of the University of + * iperf, Copyright (c) 2014-2022, The Regents of the University of * California, through Lawrence Berkeley National Laboratory (subject * to receipt of any required approvals from the U.S. Dept. of * Energy). All rights reserved. @@ -62,7 +62,7 @@ main(int argc, char **argv) // XXX: Setting the process affinity requires root on most systems. // Is this a feature we really need? #ifdef TEST_PROC_AFFINITY - /* didnt seem to work.... */ + /* didn't seem to work.... */ /* * increasing the priority of the process to minimise packet generation * delay @@ -74,7 +74,7 @@ main(int argc, char **argv) fprintf(stderr, "setting priority to valid level\n"); rc = setpriority(PRIO_PROCESS, 0, 0); } - + /* setting the affinity of the process */ cpu_set_t cpu_set; int affinity = -1; @@ -101,7 +101,7 @@ main(int argc, char **argv) if (iperf_parse_arguments(test, argc, argv) < 0) { iperf_err(test, "parameter error - %s", iperf_strerror(i_errno)); fprintf(stderr, "\n"); - usage_long(stdout); + usage(); exit(1); } @@ -151,14 +151,21 @@ run(struct iperf_test *test) for (;;) { int rc; rc = iperf_run_server(test); + test->server_last_run_rc = rc; if (rc < 0) { iperf_err(test, "error - %s", iperf_strerror(i_errno)); + if (test->json_output) { + if (iperf_json_finish(test) < 0) + return -1; + } + iflush(test); + if (rc < -1) { iperf_errexit(test, "exiting"); } } iperf_reset_test(test); - if (iperf_get_test_one_off(test)) { + if (iperf_get_test_one_off(test) && rc != 2) { /* Authentication failure doesn't count for 1-off test */ if (rc < 0 && i_errno == IEAUTHTEST) { continue; @@ -169,8 +176,13 @@ run(struct iperf_test *test) iperf_delete_pidfile(test); break; case 'c': + if (iperf_create_pidfile(test) < 0) { + i_errno = IEPIDFILE; + iperf_errexit(test, "error - %s", iperf_strerror(i_errno)); + } if (iperf_run_client(test) < 0) iperf_errexit(test, "error - %s", iperf_strerror(i_errno)); + iperf_delete_pidfile(test); break; default: usage();