net: uqmi: fix blocking in endless loops when unplugging device
authorAlexandru Ardelean <ardeleanalex@gmail.com>
Fri, 29 Sep 2017 13:35:30 +0000 (16:35 +0300)
committerAlexander Couzens <lynxis@fe80.eu>
Mon, 9 Oct 2017 14:07:42 +0000 (16:07 +0200)
If you unplug a QMI device, the /dev/cdc-wdmX device
disappears but uqmi will continue to poll it endlessly.

Then, when you plug it back, you have 2 uqmi processes,
and that's bad, because 2 processes talking QMI to the
same device [and the same time] doesn't seem to work well.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh

index 35de6c5ad5eb6059336eaf436cf7ba67b2415e68..f5c8768601081b3ddc42a9952073a9a4c35b2171 100755 (executable)
@@ -65,6 +65,7 @@ proto_qmi_setup() {
        [ -n "$delay" ] && sleep "$delay"
 
        while uqmi -s -d "$device" --get-pin-status | grep '"UIM uninitialized"' > /dev/null; do
        [ -n "$delay" ] && sleep "$delay"
 
        while uqmi -s -d "$device" --get-pin-status | grep '"UIM uninitialized"' > /dev/null; do
+               [ -e "$device" ] || return 1
                sleep 1;
        done
 
                sleep 1;
        done
 
@@ -102,6 +103,7 @@ proto_qmi_setup() {
 
        echo "Waiting for network registration"
        while uqmi -s -d "$device" --get-serving-system | grep '"searching"' > /dev/null; do
 
        echo "Waiting for network registration"
        while uqmi -s -d "$device" --get-serving-system | grep '"searching"' > /dev/null; do
+               [ -e "$device" ] || return 1
                sleep 5;
        done
 
                sleep 5;
        done