From 775341de119d354c53cc3840caf4f2cdb8673442 Mon Sep 17 00:00:00 2001 From: Mark Feit Date: Thu, 2 Sep 2021 17:20:26 -0400 Subject: [PATCH] Exit if idle time expires waiting for a connection in one-off mode. #1187 (#1197) --- src/iperf3.1 | 8 +++++++- src/iperf_server_api.c | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/iperf3.1 b/src/iperf3.1 index abab35894..41fa2b143 100644 --- a/src/iperf3.1 +++ b/src/iperf3.1 @@ -195,7 +195,13 @@ run in server mode run the server in background as a daemon .TP .BR -1 ", " --one-off -handle one client connection, then exit. +handle one client connection, then exit. If an idle time is set, the +server will exit after that amount of time with no connection. +.TP +.BR --idle-timeout " \fIn\fR" +restart the server after \fIn\fR seconds in case it gets stuck. In +one-off mode, this is the number of seconds the server will wait +before exiting. .TP .BR --server-bitrate-limit " \fIn\fR[KMGT]" set a limit on the server side, which will cause a test to abort if diff --git a/src/iperf_server_api.c b/src/iperf_server_api.c index 500ff73da..480c930fd 100644 --- a/src/iperf_server_api.c +++ b/src/iperf_server_api.c @@ -525,6 +525,13 @@ iperf_run_server(struct iperf_test *test) printf("Server restart (#%d) in idle state as no connection request was received for %d sec\n", test->server_forced_idle_restarts_count, test->settings->idle_timeout); cleanup_server(test); + if ( iperf_get_test_one_off(test) ) { + if (test->debug) + printf("No connection request was received for %d sec in one-off mode; exiting.\n", + test->settings->idle_timeout); + exit(0); + } + return 2; } }