summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-02-15 12:16:37 +0100
committerGitHub <noreply@github.com>2019-02-15 12:16:37 +0100
commitbbd8598f8b8939a86751c04e823aaccce3ffd3f8 (patch)
tree962703dc9d8e7501bb6baf7e747bb879cc771cbd /src
parent646876105fe1799355715839477958adf1d096fd (diff)
parent8671411668e9b15bc3dadcb4e48ff43f6a8461d3 (diff)
downloadsystemd-bbd8598f8b8939a86751c04e823aaccce3ffd3f8.tar.gz
systemd-bbd8598f8b8939a86751c04e823aaccce3ffd3f8.tar.bz2
systemd-bbd8598f8b8939a86751c04e823aaccce3ffd3f8.zip
Merge pull request #11589 from yuwata/udevd-is-device-busy
udevd: refactoring is_device_busy()
Diffstat (limited to 'src')
-rw-r--r--src/udev/udevd.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 0303f36b4f..a5c24a70f4 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -727,7 +727,7 @@ static int is_device_busy(Manager *manager, struct event *event) {
if (sd_device_get_devnum(loop_event->dev, &d) >= 0 &&
devnum == d && is_block == streq(s, "block"))
- return true;
+ goto set_delaying_seqnum;
}
/* check network device ifindex */
@@ -736,17 +736,15 @@ static int is_device_busy(Manager *manager, struct event *event) {
if (sd_device_get_ifindex(loop_event->dev, &i) >= 0 &&
ifindex == i)
- return true;
+ goto set_delaying_seqnum;
}
if (sd_device_get_devpath(loop_event->dev, &loop_devpath) < 0)
continue;
/* check our old name */
- if (devpath_old && streq(devpath_old, loop_devpath)) {
- event->delaying_seqnum = loop_event->seqnum;
- return true;
- }
+ if (devpath_old && streq(devpath_old, loop_devpath))
+ goto set_delaying_seqnum;
loop_devpath_len = strlen(loop_devpath);
@@ -758,28 +756,23 @@ static int is_device_busy(Manager *manager, struct event *event) {
continue;
/* identical device event found */
- if (devpath_len == loop_devpath_len) {
- /* devices names might have changed/swapped in the meantime */
- if (major(devnum) != 0 || ifindex > 0)
- continue;
- event->delaying_seqnum = loop_event->seqnum;
- return true;
- }
+ if (devpath_len == loop_devpath_len)
+ goto set_delaying_seqnum;
/* parent device event found */
- if (devpath[common] == '/') {
- event->delaying_seqnum = loop_event->seqnum;
- return true;
- }
+ if (devpath[common] == '/')
+ goto set_delaying_seqnum;
/* child device event found */
- if (loop_devpath[common] == '/') {
- event->delaying_seqnum = loop_event->seqnum;
- return true;
- }
+ if (loop_devpath[common] == '/')
+ goto set_delaying_seqnum;
}
return false;
+
+set_delaying_seqnum:
+ event->delaying_seqnum = loop_event->seqnum;
+ return true;
}
static int on_exit_timeout(sd_event_source *s, uint64_t usec, void *userdata) {