Skip to content

Commit

Permalink
[udev] Do not exit if cable state can't be determined
Browse files Browse the repository at this point in the history
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 <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Dec 1, 2017
1 parent 0d5a10b commit 22bcd9f
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/usb_moded-udev.c
Expand Up @@ -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
Expand All @@ -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();
Expand Down

0 comments on commit 22bcd9f

Please sign in to comment.