--- embedaddon/iperf/src/main.c 2016/10/18 13:28:18 1.1.1.1 +++ embedaddon/iperf/src/main.c 2021/03/17 00:36:46 1.1.1.2 @@ -1,5 +1,5 @@ /* - * iperf, Copyright (c) 2014, 2015, The Regents of the University of + * iperf, Copyright (c) 2014, 2015, 2017, 2019, 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. @@ -41,16 +41,13 @@ #include #include #include -#ifdef HAVE_STDINT_H -#include -#endif -#include #include "iperf.h" #include "iperf_api.h" -#include "units.h" +#include "iperf_util.h" #include "iperf_locale.h" #include "net.h" +#include "units.h" static int run(struct iperf_test *test); @@ -104,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(); + usage_long(stdout); exit(1); } @@ -119,7 +116,7 @@ main(int argc, char **argv) static jmp_buf sigend_jmp_buf; -static void +static void __attribute__ ((noreturn)) sigend_handler(int sig) { longjmp(sigend_jmp_buf, 1); @@ -134,10 +131,14 @@ run(struct iperf_test *test) if (setjmp(sigend_jmp_buf)) iperf_got_sigend(test); + /* Ignore SIGPIPE to simplify error handling */ + signal(SIGPIPE, SIG_IGN); + switch (test->role) { case 's': if (test->daemon) { - int rc = daemon(0, 0); + int rc; + rc = daemon(0, 0); if (rc < 0) { i_errno = IEDAEMON; iperf_errexit(test, "error - %s", iperf_strerror(i_errno)); @@ -154,12 +155,16 @@ run(struct iperf_test *test) iperf_err(test, "error - %s", iperf_strerror(i_errno)); if (rc < -1) { iperf_errexit(test, "exiting"); - break; } } iperf_reset_test(test); - if (iperf_get_test_one_off(test)) - break; + if (iperf_get_test_one_off(test)) { + /* Authentication failure doesn't count for 1-off test */ + if (rc < 0 && i_errno == IEAUTHTEST) { + continue; + } + break; + } } iperf_delete_pidfile(test); break; @@ -173,6 +178,7 @@ run(struct iperf_test *test) } iperf_catch_sigend(SIG_DFL); + signal(SIGPIPE, SIG_DFL); return 0; }