mirror of
https://github.com/AuxXxilium/eudev.git
synced 2025-01-24 08:00:08 +07:00
[PATCH] improve event sequence serialization
We delay the execution of events if there is already an event running for the same device, a parent or a child device. "add" events with a reference to a physical device will also wait for the physical device to finish. Here we fix the devpath comparison logic to return "busy" only if a complete device names is matching. /block/sdaa will not longer block a /block/sda event.
This commit is contained in:
parent
e750d24b05
commit
7b6571a9fc
55
udevd.c
55
udevd.c
@ -151,34 +151,51 @@ static void udev_run(struct hotplug_msg *msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns still running task for the same event sequence */
|
static int compare_devpath(const char *running, const char *waiting)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < DEVPATH_SIZE; i++) {
|
||||||
|
/* identical device event found */
|
||||||
|
if (running[i] == '\0' && waiting[i] == '\0')
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* parent device event found */
|
||||||
|
if (running[i] == '\0' && waiting[i] == '/')
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
/* child device event found */
|
||||||
|
if (running[i] == '/' && waiting[i] == '\0')
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
/* no matching event */
|
||||||
|
if (running[i] != waiting[i])
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* returns still running task for the same device, its parent or its physical device */
|
||||||
static struct hotplug_msg *running_with_devpath(struct hotplug_msg *msg)
|
static struct hotplug_msg *running_with_devpath(struct hotplug_msg *msg)
|
||||||
{
|
{
|
||||||
struct hotplug_msg *loop_msg;
|
struct hotplug_msg *loop_msg;
|
||||||
int i;
|
|
||||||
|
if (msg->devpath == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
list_for_each_entry(loop_msg, &running_list, list) {
|
list_for_each_entry(loop_msg, &running_list, list) {
|
||||||
if (loop_msg->devpath == NULL || msg->devpath == NULL)
|
if (loop_msg->devpath == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* is a parent or child device event still running */
|
/* return running parent/child device event */
|
||||||
for (i = 0; i < DEVPATH_SIZE; i++) {
|
if (compare_devpath(loop_msg->devpath, msg->devpath) != 0)
|
||||||
if (loop_msg->devpath[i] == '\0' || msg->devpath[i] == '\0')
|
return loop_msg;
|
||||||
return loop_msg;
|
|
||||||
|
|
||||||
if (loop_msg->devpath[i] != msg->devpath[i])
|
/* return running physical device event */
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* is the physical device event still running on an add sequence */
|
|
||||||
if (msg->physdevpath && msg->action && strcmp(msg->action, "add") == 0)
|
if (msg->physdevpath && msg->action && strcmp(msg->action, "add") == 0)
|
||||||
for (i = 0; i < DEVPATH_SIZE; i++) {
|
if (compare_devpath(loop_msg->devpath, msg->physdevpath) != 0)
|
||||||
if (loop_msg->devpath[i] == '\0' || msg->physdevpath[i] == '\0')
|
return loop_msg;
|
||||||
return loop_msg;
|
|
||||||
|
|
||||||
if (loop_msg->devpath[i] != msg->physdevpath[i])
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user