Multiple "wifi up/down" invocations can conflict badly with each other
resulting in a somehow broken wifi setup.

This can be triggered by calling "/etc/init.d/network reload" quickly
after netifd started up (before the sleep 5 has finished).

This is a first try to synchronize the usage of "wifi up/down".

Signed-off-by: Helmut Schaa <[email protected]>
---

Sending as RFC since I consider this an ugly hack and somebody else might have 
a better idea.
Helmut


 .../network/config/netifd/files/etc/init.d/network |   23 ++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/package/network/config/netifd/files/etc/init.d/network 
b/package/network/config/netifd/files/etc/init.d/network
index 8031802..5c977a8 100755
--- a/package/network/config/netifd/files/etc/init.d/network
+++ b/package/network/config/netifd/files/etc/init.d/network
@@ -5,6 +5,15 @@ STOP=90
 
 USE_PROCD=1
 
+wait_lock() {
+       lock /var/run/network.lock
+       trap 'lock -u /var/run/network.lock' EXIT
+}
+
+unlock() {
+       lock -u /var/run/network.lock
+}
+
 start_service() {
        [ -e /proc/sys/kernel/core_pattern ] && {
                ulimit -c unlimited
@@ -18,12 +27,22 @@ start_service() {
 
 reload_service() {
        ubus call network reload
+       
+       # don't run multiple wifi commands in parallel
+       wait_lock
+
        /sbin/wifi down
        /sbin/wifi up
+
+       unlock
 }
 
 stop_service() {
+       wait_lock
+
        /sbin/wifi down
+
+       unlock
 }
 
 service_running() {
@@ -32,10 +51,14 @@ service_running() {
        include /lib/network
        setup_switch
 
+       wait_lock
+
        sleep 5
 
        /sbin/wifi down
        /sbin/wifi up
+
+       unlock
 }
 
 service_triggers()
-- 
1.7.10.4
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to