From 77c88f2738aac492929f544c45134ee341e56938 Mon Sep 17 00:00:00 2001 From: Tim Wilkinson Date: Fri, 29 Apr 2022 11:26:48 -0700 Subject: [PATCH] Wait for iperf3 daemon to startup before returning. (#350) --- files/www/cgi-bin/iperf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/files/www/cgi-bin/iperf b/files/www/cgi-bin/iperf index e5c6c59d..fc76e5c8 100755 --- a/files/www/cgi-bin/iperf +++ b/files/www/cgi-bin/iperf @@ -36,6 +36,7 @@ require("uci") require("luci.sys") +require("nixio") local q = os.getenv("QUERY_STRING") or "" local server = q:match("server=([^&]*)") @@ -51,6 +52,13 @@ elseif not server then print("
Provide a server name to run a test between this client and a server [/cgi-bin/iperf?server=<ServerName>&protocol=<udp|tcp>]
") elseif server == "" then os.execute("killall iperf3; iperf3 -s -D -1") + for _ = 1,5 + do + if io.popen("netstat -ln | grep 0.0.0.0:5201"):read("*a") ~= "" then + break + end + nixio.nanosleep(1, 0) + end print("
iperf server running (one time)
") elseif server:match("[^%w-%.]") then print("
Illegal server name
")