Skip to content

Commit ccd88fb

Browse files
ecsvskorpy2009
authored andcommitted
ffffm-ath9k-broken-wifi-workaround: Avoid overlong sleeps
The ath9k workaround is using a sleep before starting a batctl ping. The time for the sleep is calculated using awk and should be between 0-24 seconds. The duration is then tried to be stored in $RANDOM. Unfortunately, $RANDOM is a special variable in bash/ksh/... which always returns a "different" random value when read. This behavior is also enabled in ash when CONFIG_ASH_RANDOM_SUPPORT is enabled - which is the case since OpenWrt commit 8f427f1a058d ("busybox: turn on BUSYBOX_DEFAULT_ASH_RANDOM_SUPPORT for having $RANDOM"). The script is therefore creating sleep durations of 0-32767s since OpenWrt 23.05. As result, the script either: * for versions without the LOCK: the number of sleep processes (and related ash processes) increase steadily and after some time use up all memory on the system. * for versions with the LOCK: the script will not do anything (besides logging "Another instance is still running, aborting.") for a long time Just rename the variable to avoid this problem. Signed-off-by: Sven Eckelmann <sven@narfation.org>
1 parent 3405179 commit ccd88fb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

ffffm-ath9k-broken-wifi-workaround/files/lib/gluon/ath9k-broken-wifi-workaround/ath9k-broken-wifi-workaround.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ done
199199
GWCONNECTION=0
200200
GATEWAY=$(batctl gwl | grep -e "^=>" -e "^\*" | awk -F'[ ]' '{print $2}')
201201
if [ $GATEWAY ]; then
202-
RANDOM=$(awk 'BEGIN { srand(); printf("%d\n",rand()*25) }')
203-
sleep $RANDOM
202+
RANDSLEEP=$(awk 'BEGIN { srand(); printf("%d\n",rand()*25) }')
203+
sleep $RANDSLEEP
204204
batctl ping -c 5 $GATEWAY > /dev/null 2>&1
205205
if [ $? -eq 0 ]; then
206206
GWCONNECTION=1

0 commit comments

Comments
 (0)