X Tutup
Skip to content

Commit 4029328

Browse files
yuwatapoettering
authored andcommitted
udev: remove /run/udev/queue in on_post()
When the last queued event is processed, information about subsequent events may be already queued in the netlink socket of sd-device-monitor. In that case, previously we once removed /run/udev/queue and touch the file soon later, and `udevadm settle` mistakenly considered all events are processed. To mitigate such situation, this makes /run/udev/queue removed in on_post().
1 parent 9612da3 commit 4029328

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/udev/udevd.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,6 @@ static Event *event_free(Event *event) {
171171
if (event->worker)
172172
event->worker->event = NULL;
173173

174-
/* only clean up the queue from the process that created it */
175-
if (LIST_IS_EMPTY(event->manager->events) &&
176-
event->manager->pid == getpid_cached())
177-
if (unlink("/run/udev/queue") < 0 && errno != ENOENT)
178-
log_warning_errno(errno, "Failed to unlink /run/udev/queue, ignoring: %m");
179-
180174
return mfree(event);
181175
}
182176

@@ -1480,7 +1474,13 @@ static int on_post(sd_event_source *s, void *userdata) {
14801474
if (!LIST_IS_EMPTY(manager->events))
14811475
return 1;
14821476

1483-
/* There are no pending events. Let's cleanup idle process. */
1477+
/* There are no queued events. Let's remove /run/udev/queue and clean up the idle processes. */
1478+
1479+
if (unlink("/run/udev/queue") < 0) {
1480+
if (errno != ENOENT)
1481+
log_warning_errno(errno, "Failed to unlink /run/udev/queue, ignoring: %m");
1482+
} else
1483+
log_debug("No events are queued, removing /run/udev/queue.");
14841484

14851485
if (!hashmap_isempty(manager->workers)) {
14861486
/* There are idle workers */

0 commit comments

Comments
 (0)
X Tutup