wifi-presence icon indicating copy to clipboard operation
wifi-presence copied to clipboard

OpenWrt Boot racecondition

Open jmccrohan opened this issue 2 years ago • 2 comments

Hi Adam,

I've noticed that wifi-presence does not start cleanly on boot for me. I suspect the issue is that hostapd hasn't started yet, and there are no control sockets found by wifi-presence when it starts.

root@ap-office:~# logread | grep wifi-presence
Fri Apr 22 17:08:51 2022 daemon.err wifi-presence[2366]: Error: hostapd.socks cannot be blank

Restarting the process manually after boot is fine, so I'm not sure what the best way of resolving this is, whether it be through procd, or through wifi-presence itself.

Cheers, Jon

jmccrohan avatar Apr 22 '22 16:04 jmccrohan

Thanks for the report. I've noticed that too, where wifi-presence fails to start likely because of what you described. In my case though, procd restarts it and eventually it works.

We could consider something like the following in the start_service function.

for i in 1 2 3 4 5 6 7 8 9 10; do
	if [ -d "${hostapdSockDir}" ] && find "${hostapdSockDir}" -type s | grep . >/dev/null; then
		# hostapd socket(s) found
		break
	fi
	# No hostapd socket found, retrying in 1s
	sleep 1
done

The START=95 setting should mean that wifi-presence is started after hostapd (START=19).

awilliams avatar Apr 23 '22 04:04 awilliams

Thanks. Yes, this approach makes sense to me. Do you want to roll the fix for this and #3 into a single PR?

jmccrohan avatar Apr 28 '22 22:04 jmccrohan