mwan3: fix race condition in route loading
authorAaron Goodman <aaronjg@stanford.edu>
Sun, 13 Dec 2020 14:27:03 +0000 (09:27 -0500)
committerFlorian Eckert <fe@dev.tdt.de>
Wed, 16 Dec 2020 08:32:13 +0000 (09:32 +0100)
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
net/mwan3/files/usr/sbin/mwan3rtmon

index e460615edc60449a5a82179bb8a4e6da119c2100..44cd28a911c76ed35f0aba5f5d9a467ad16c6ceb 100755 (executable)
@@ -158,6 +158,7 @@ main()
        sh -c "echo \$\$; exec $IP monitor route" | {
                read -r monitor_pid
                trap_with_arg func_trap "$monitor_pid" SIGINT SIGTERM SIGKILL
+               KILL -SIGSTOP $$
                while IFS='' read -r line; do
                        [ -z "${line##*table*}" ] && continue
                        LOG debug "handling route update $family '$line'"
@@ -165,11 +166,10 @@ main()
                done
        } &
        child=$!
-       kill -SIGSTOP $child
        trap_with_arg func_trap "$child" SIGINT SIGTERM SIGKILL
        mwan3_set_connected_${family}
        mwan3_add_all_routes ${family}
        kill -SIGCONT $child
-       wait $!
+       wait $child
 }
 main "$@"