Skip to content

Commit 17b43e2

Browse files
committed
udev: try again to create /run/udev/queue when queueing the next event
This is mostly a paranoia, but if we failed to create /run/udev/queue for some reasons on queueing an event, previously we would never create the file until once the queue became empty. This makes in such case we try to create the file again when queueing the next event.
1 parent d93292b commit 17b43e2

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/udev/udev-manager.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -852,16 +852,17 @@ static int event_queue_insert(Manager *manager, sd_device *dev) {
852852
.state = EVENT_QUEUED,
853853
};
854854

855-
if (!manager->events) {
855+
LIST_APPEND(event, manager->events, event);
856+
log_device_uevent(dev, "Device is queued");
857+
858+
if (!manager->queue_file_created) {
856859
r = touch("/run/udev/queue");
857860
if (r < 0)
858861
log_warning_errno(r, "Failed to touch /run/udev/queue, ignoring: %m");
862+
else
863+
manager->queue_file_created = true;
859864
}
860865

861-
LIST_APPEND(event, manager->events, event);
862-
863-
log_device_uevent(dev, "Device is queued");
864-
865866
return 0;
866867
}
867868

@@ -1155,13 +1156,12 @@ static int manager_unlink_queue_file(Manager *manager) {
11551156

11561157
/* There are no queued events. Let's remove /run/udev/queue and clean up the idle processes. */
11571158
if (unlink("/run/udev/queue") < 0) {
1158-
if (errno == ENOENT)
1159-
return 0;
1160-
1161-
return log_warning_errno(errno, "Failed to unlink /run/udev/queue: %m");
1162-
}
1159+
if (errno != ENOENT)
1160+
return log_warning_errno(errno, "Failed to unlink /run/udev/queue: %m");
1161+
} else
1162+
log_debug("No events are queued, removed /run/udev/queue.");
11631163

1164-
log_debug("No events are queued, removed /run/udev/queue.");
1164+
manager->queue_file_created = false;
11651165
return 0;
11661166
}
11671167

src/udev/udev-manager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ typedef struct Manager {
6161
UdevConfig config_by_control;
6262
UdevConfig config;
6363

64+
bool queue_file_created;
6465
bool stop_exec_queue;
6566
bool exit;
6667
} Manager;

0 commit comments

Comments
 (0)