From 22bcd9f42e7a2d81ef8a66a1f9c07d0fe2eb2fb6 Mon Sep 17 00:00:00 2001 From: Simo Piiroinen Date: Fri, 1 Dec 2017 15:24:06 +0200 Subject: [PATCH] [udev] Do not exit if cable state can't be determined If usb-moded exits when it can't deduce cable connect state, it will be restarted by systemd. As the usb-moded restarts are not going to change how the udev status looks like, this repeats until systemd moves the usb-moded service to failed state. Do not exit and assume no usb-cable is connected. In addition to not triggering restart spree, this has the additional benefit that the usb-moded dbus interface stays available and signaling not-connected state. Signed-off-by: Simo Piiroinen --- src/usb_moded-udev.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/usb_moded-udev.c b/src/usb_moded-udev.c index fddcd85..7d86cd3 100644 --- a/src/usb_moded-udev.c +++ b/src/usb_moded-udev.c @@ -405,14 +405,7 @@ static void udev_parse(struct udev_device *dev, bool initial) power_supply_online = udev_device_get_property_value(dev, "POWER_SUPPLY_ONLINE"); } - if (!power_supply_present) { - log_err("No usable power supply indicator\n"); - /* TRY AGAIN? - return; */ - exit(1); - } - - if (!strcmp(power_supply_present, "1")) + if (power_supply_present && !strcmp(power_supply_present, "1")) connected = true; /* Transition period = Connection status derived from udev @@ -426,6 +419,9 @@ static void udev_parse(struct udev_device *dev, bool initial) /* disconnect */ if (!connected) { + if (warnings && !power_supply_present) + log_err("No usable power supply indicator\n"); + log_debug("DISCONNECTED"); cancel_cable_connection_timeout();